From c19f6525465065496c485a5084a86707e4923580 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 5 Feb 2019 23:51:13 +0100 Subject: Port custom modules to python3. --- lib/modules/fetch_cmd.py | 4 ++-- lib/modules/mysql_user2 | 4 ++-- lib/modules/openldap | 10 +++++----- lib/modules/postmap | 4 ++-- lib/modules/postmulti | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/modules/fetch_cmd.py b/lib/modules/fetch_cmd.py index ac8757f..ca3e817 100644 --- a/lib/modules/fetch_cmd.py +++ b/lib/modules/fetch_cmd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Fetch the output of a remote command # Copyright (c) 2016 Guilhem Moulin @@ -48,7 +48,7 @@ def main(): if stdin is not None: stdin.close() - except KeyError, e: + except KeyError as e: module.fail_json(msg=str(e)) module.exit_json(changed=changed) diff --git a/lib/modules/mysql_user2 b/lib/modules/mysql_user2 index f2d9d40..20742fe 100644 --- a/lib/modules/mysql_user2 +++ b/lib/modules/mysql_user2 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # (c) 2012, Mark Theunissen # Sponsored by Four Kitchens http://fourkitchens.com. @@ -472,7 +472,7 @@ def main(): if not cursor: cursor = connect(module, login_user, login_password) - except Exception, e: + except Exception as e: module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials") if state == "present": diff --git a/lib/modules/openldap b/lib/modules/openldap index 9b015b6..9afe1f1 100644 --- a/lib/modules/openldap +++ b/lib/modules/openldap @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Manage OpenLDAP databases # Copyright (c) 2013 Guilhem Moulin @@ -303,7 +303,7 @@ def main(): try: r = l.search_s( name, ldap.SCOPE_BASE, filterStr, attrsonly=1 ) - except ldap.LDAPError, ldap.NO_SUCH_OBJECT: + except (ldap.LDAPError, ldap.NO_SUCH_OBJECT): r = None if r: @@ -352,9 +352,9 @@ def main(): changed = parser.changed l.unbind_s() - except subprocess.CalledProcessError, e: + except subprocess.CalledProcessError as e: module.fail_json(rv=e.returncode, msg=e.output.rstrip()) - except ldap.LDAPError, e: + except ldap.LDAPError as e: e = e.args[0] if 'info' in e.keys(): msg = e['info'] @@ -363,7 +363,7 @@ def main(): else: msg = str(e) module.fail_json(msg=msg) - except KeyError, e: + except KeyError as e: module.fail_json(msg=str(e)) module.exit_json(changed=changed) diff --git a/lib/modules/postmap b/lib/modules/postmap index 8c9d54c..ce09018 100644 --- a/lib/modules/postmap +++ b/lib/modules/postmap @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Create or update postfix's alias and lookup tables # Copyright (c) 2013 Guilhem Moulin @@ -97,7 +97,7 @@ def main(): changed = True if not module.check_mode: msg = compile( cmd, instance, db, src) - except subprocess.CalledProcessError, e: + except subprocess.CalledProcessError as e: module.fail_json(rv=e.returncode, msg=e.output.rstrip()) changed = module.set_file_attributes_if_different(file_args, changed) diff --git a/lib/modules/postmulti b/lib/modules/postmulti index d6ecb09..3c0a522 100644 --- a/lib/modules/postmulti +++ b/lib/modules/postmulti @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Create and manage postfix instances. # Copyright (c) 2013 Guilhem Moulin @@ -94,7 +94,7 @@ def main(): module.exit_json(changed=changed) - except subprocess.CalledProcessError, e: + except subprocess.CalledProcessError as e: module.fail_json(rv=e.returncode, msg=e.output.rstrip()) -- cgit v1.2.3