This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master
in repository lib389.
commit b28ef1862b0a69942cd664733e4e8c3ebf3715ad
Author: Ilias Stamatis <stamatis.iliass(a)gmail.com>
Date: Tue Jun 27 04:14:28 2017 +0300
Issue 67 - Add ensure_int function
Bug Description: get_attr_val_int("attr") method raises an Exception if
the requested attribute does not exist. All other similar methods return
None in that case.
Fix Description: Add a new ensure_int() utility function that checks
against None, in consistency with existing functions.
https://pagure.io/lib389/issue/67
Author: Ilias95
Review by: wibrown (Thank you very much!)
---
lib389/_mapped_object.py | 14 ++++++++------
lib389/tests/tls_external_test.py | 5 ++---
lib389/utils.py | 20 ++++++++++++++++----
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/lib389/_mapped_object.py b/lib389/_mapped_object.py
index c9b7eb9..6ed141b 100644
--- a/lib389/_mapped_object.py
+++ b/lib389/_mapped_object.py
@@ -10,13 +10,15 @@ import ldap
import ldap.dn
from ldap import filter as ldap_filter
import logging
-
-from lib389._constants import *
-from lib389.utils import ensure_bytes, ensure_str, ensure_list_bytes, ensure_list_str
+from functools import partial
from lib389._entry import Entry
+from lib389._constants import DIRSRV_STATE_ONLINE
+from lib389.utils import (
+ ensure_bytes, ensure_str, ensure_int, ensure_list_bytes, ensure_list_str,
+ ensure_list_int
+ )
-from functools import partial
# This function filter and term generation provided thanks to
# The University of Adelaide. <william(a)adelaide.edu.au>
@@ -348,10 +350,10 @@ class DSLdapObject(DSLogging):
return ensure_list_str(self.get_attrs_val(key))
def get_attr_val_int(self, key):
- return int(self.get_attr_val(key))
+ return ensure_int(self.get_attr_val(key))
def get_attr_vals_int(self, key):
- return [int(v) for v in self.get_attrs_val(key)]
+ return ensure_list_int(self.get_attrs_val(key))
# Duplicate, but with many values. IE a dict api.
# This
diff --git a/lib389/tests/tls_external_test.py b/lib389/tests/tls_external_test.py
index 3eef771..68aaa9d 100644
--- a/lib389/tests/tls_external_test.py
+++ b/lib389/tests/tls_external_test.py
@@ -7,13 +7,12 @@
# --- END COPYRIGHT BLOCK ---
#
-import pytest
import ldap
from lib389.topologies import topology_st
-from lib389.utils import *
-from lib389.sasl import PlainSASL
+from lib389.utils import logging
from lib389.idm.user import UserAccounts
+from lib389._constants import DEFAULT_SUFFIX, SECUREPORT_STANDALONE1
from lib389.config import CertmapLegacy
diff --git a/lib389/utils.py b/lib389/utils.py
index 2108475..e022d0f 100644
--- a/lib389/utils.py
+++ b/lib389/utils.py
@@ -29,7 +29,6 @@ import logging
import shutil
import ldap
import socket
-import subprocess
import time
import sys
import filecmp
@@ -37,9 +36,14 @@ from socket import getfqdn
from ldapurl import LDAPUrl
from contextlib import closing
-from lib389._constants import *
-from lib389.properties import *
+import lib389
from lib389.paths import Paths
+from lib389._constants import DEFAULT_USER, VALGRIND_WRAPPER, DN_CONFIG, CFGSUFFIX
+from lib389.properties import (
+ SER_HOST, SER_USER_ID, SER_GROUP_ID, SER_STRICT_HOSTNAME_CHECKING, SER_PORT,
+ SER_ROOT_DN, SER_ROOT_PW, SER_SERVERID_PROP, SER_CREATION_SUFFIX,
+ SER_INST_SCRIPTS_ENABLED
+ )
MAJOR, MINOR, _, _, _ = sys.version_info
@@ -582,7 +586,7 @@ def getcfgdsinfo(new_instance_arguments):
try:
return (new_instance_arguments['cfgdshost'],
int(new_instance_arguments['cfgdsport']),
- lib389.CFGSUFFIX)
+ CFGSUFFIX)
except KeyError: # if keys are missing...
if new_instance_arguments['new_style']:
return getnewcfgdsinfo(new_instance_arguments)
@@ -787,12 +791,20 @@ def ensure_str(val):
return val.decode('utf-8')
return val
+def ensure_int(val):
+ if val is not None and not isinstance(val, int):
+ return int(val)
+ return val
+
def ensure_list_bytes(val):
return [ensure_bytes(v) for v in val]
def ensure_list_str(val):
return [ensure_str(v) for v in val]
+def ensure_list_int(val):
+ return [ensure_int(v) for v in val]
+
def ensure_dict_str(val):
if MAJOR <= 2:
return val
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.