From bb4b558164d4f33ca09b9c2b2fbeb0de3280e00b Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 26 Nov 2018 11:42:56 +0100 Subject: [PATCH] Address misc pylint issues in CLI scripts The CLI script files have additional pylint issues that were not noticed before. The violations include using dict.keys() without directly iterating of the result, inconsistent return statements and set([]) instead of set literals. * dict-keys-not-iterating * inconsistent-return-statements * onsider-using-set-comprehensio See: https://pagure.io/freeipa/issue/7772 Signed-off-by: Christian Heimes Reviewed-By: Thomas Woerner --- install/tools/ipa-csreplica-manage.in | 3 +-- install/tools/ipa-httpd-kdcproxy.in | 2 ++ install/tools/ipa-replica-conncheck.in | 1 + install/tools/ipa-replica-manage.in | 14 +++++++------- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/install/tools/ipa-csreplica-manage.in b/install/tools/ipa-csreplica-manage.in index b9ad3775e..716e3434b 100644 --- a/install/tools/ipa-csreplica-manage.in +++ b/install/tools/ipa-csreplica-manage.in @@ -70,8 +70,7 @@ def parse_options(): if len(args): n = len(args) - 1 - k = commands.keys() - for cmd in k: + for cmd in commands: if cmd == args[0]: v = commands[cmd] err = None diff --git a/install/tools/ipa-httpd-kdcproxy.in b/install/tools/ipa-httpd-kdcproxy.in index 685e9b612..539b7f1e4 100644 --- a/install/tools/ipa-httpd-kdcproxy.in +++ b/install/tools/ipa-httpd-kdcproxy.in @@ -209,6 +209,8 @@ def main(debug=DEBUG, time_limit=TIME_LIMIT): except Exception as e: logger.error('%s', str(e)) return 1 + else: + return 0 if __name__ == '__main__': diff --git a/install/tools/ipa-replica-conncheck.in b/install/tools/ipa-replica-conncheck.in index 8792c6772..5cb14c7dc 100644 --- a/install/tools/ipa-replica-conncheck.in +++ b/install/tools/ipa-replica-conncheck.in @@ -637,6 +637,7 @@ def main(): time.sleep(3600) logger.info( "Connection check timeout: terminating listening program") + return 0 if __name__ == "__main__": diff --git a/install/tools/ipa-replica-manage.in b/install/tools/ipa-replica-manage.in index c3ad177a6..35d412c2e 100644 --- a/install/tools/ipa-replica-manage.in +++ b/install/tools/ipa-replica-manage.in @@ -111,8 +111,7 @@ def parse_options(): if len(args): n = len(args) - 1 - k = commands.keys() - for cmd in k: + for cmd in commands: if cmd == args[0]: v = commands[cmd] err = None @@ -432,7 +431,7 @@ def get_ruv_both_suffixes(realm, host, dirman_passwd, verbose, nolookup=False): print(err) logger.debug('%s', err) - if not ruvs.keys(): + if not ruvs: raise NoRUVsFound("No RUV records found.") return ruvs @@ -480,6 +479,7 @@ def get_rid_by_host(realm, sourcehost, host, dirman_passwd, nolookup=False): for (netloc, rid) in servers: if '%s:389' % host == netloc: return int(rid) + return None def clean_ruv(realm, ruv, options): @@ -717,15 +717,15 @@ def clean_dangling_ruvs(realm, host, options): # get_ruv_both_suffixes returns server names with :port # This needs needs to be split off if ruv_dict.get('domain'): - master_info['ruvs'] = set([ + master_info['ruvs'] = { (re.sub(':\d+', '', x), y) for (x, y) in ruv_dict['domain'] - ]) + } if ruv_dict.get('ca'): - master_info['csruvs'] = set([ + master_info['csruvs'] = { (re.sub(':\d+', '', x), y) for (x, y) in ruv_dict['ca'] - ]) + } except Exception as e: sys.exit("Failed to obtain information from '{host}': {error}" .format(host=master_cn, error=str(e)))