diff options
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipaldap.py | 12 | ||||
-rw-r--r-- | ipapython/ipautil.py | 10 |
2 files changed, 15 insertions, 7 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 6873511c4..9ee0ab5f5 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -1164,7 +1164,7 @@ class LDAPClient(object): ) return self.combine_filters(flts, rules) - def get_entries(self, base_dn, scope=None, filter=None, attrs_list=None): + def get_entries(self, base_dn, scope=None, filter=None, attrs_list=None, debug=False): """Return a list of matching entries. Raises an error if the list is truncated by the server @@ -1177,14 +1177,14 @@ class LDAPClient(object): Use the find_entries method for more options. """ entries, truncated = self.find_entries( - base_dn=base_dn, scope=scope, filter=filter, attrs_list=attrs_list) + base_dn=base_dn, scope=scope, filter=filter, attrs_list=attrs_list, debug=debug) if truncated: raise errors.LimitsExceeded() return entries def find_entries(self, filter=None, attrs_list=None, base_dn=None, scope=ldap.SCOPE_SUBTREE, time_limit=None, - size_limit=None, search_refs=False): + size_limit=None, search_refs=False, debug=False): """ Return a list of entries and indication of whether the results were truncated ([(dn, entry_attrs)], truncated) matching specified search @@ -1232,14 +1232,20 @@ class LDAPClient(object): base_dn, scope, filter, attrs_list, timeout=time_limit, sizelimit=size_limit ) + if debug: + self.log.info("id: %s" % id) while True: (objtype, res_list) = self.conn.result(id, 0) + if debug: + self.log.info("res_list: %s" % res_list) if not res_list: break if (objtype == ldap.RES_SEARCH_ENTRY or (search_refs and objtype == ldap.RES_SEARCH_REFERENCE)): res.append(res_list[0]) + if debug: + self.log.info('appending to res: %s' % res_list[0]) except (ldap.ADMINLIMIT_EXCEEDED, ldap.TIMELIMIT_EXCEEDED, ldap.SIZELIMIT_EXCEEDED), e: truncated = True diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 92569c3b4..e00f3ef3f 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -246,7 +246,7 @@ def shell_quote(string): return "'" + string.replace("'", "'\\''") + "'" def run(args, stdin=None, raiseonerr=True, - nolog=(), env=None, capture_output=True, skip_output=False, cwd=None): + nolog=(), env=None, capture_output=True, skip_output=False, cwd=None, debug=False): """ Execute a command and return stdin, stdout and the process return code. @@ -295,8 +295,9 @@ def run(args, stdin=None, raiseonerr=True, p_err = subprocess.PIPE arg_string = nolog_replace(' '.join(args), nolog) - root_logger.debug('Starting external process') - root_logger.debug('args=%s' % arg_string) + if debug: + root_logger.info('Starting external process') + root_logger.info('args=%s' % arg_string) try: p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err, @@ -314,7 +315,8 @@ def run(args, stdin=None, raiseonerr=True, if skip_output: p_out.close() # pylint: disable=E1103 - root_logger.debug('Process finished, return code=%s', p.returncode) + if debug: + root_logger.info('Process finished, return code=%s', p.returncode) # The command and its output may include passwords that we don't want # to log. Replace those. |