mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Convert the network subfolder to py3/py2.4 syntax (#3690)
This commit is contained in:
parent
09066f1518
commit
c0217e14a7
20 changed files with 90 additions and 47 deletions
|
@ -114,7 +114,8 @@ def check_url(module, url):
|
|||
def run_cl_cmd(module, cmd, check_rc=True):
|
||||
try:
|
||||
(rc, out, err) = module.run_command(cmd, check_rc=check_rc)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
module.fail_json(msg=e.strerror)
|
||||
# trim last line as it is always empty
|
||||
ret = out.splitlines()
|
||||
|
|
|
@ -84,7 +84,8 @@ def hash_existing_ports_conf(module):
|
|||
|
||||
try:
|
||||
existing_ports_conf = open(PORTS_CONF).readlines()
|
||||
except IOError, error_msg:
|
||||
except IOError:
|
||||
error_msg = get_exception()
|
||||
_msg = "Failed to open %s: %s" % (PORTS_CONF, error_msg)
|
||||
module.fail_json(msg=_msg)
|
||||
return # for testing only should return on module.fail_json
|
||||
|
@ -143,7 +144,8 @@ def make_copy_of_orig_ports_conf(module):
|
|||
|
||||
try:
|
||||
shutil.copyfile(PORTS_CONF, PORTS_CONF + '.orig')
|
||||
except IOError, error_msg:
|
||||
except IOError:
|
||||
error_msg = get_exception()
|
||||
_msg = "Failed to save the original %s: %s" % (PORTS_CONF, error_msg)
|
||||
module.fail_json(msg=_msg)
|
||||
return # for testing only
|
||||
|
@ -165,7 +167,8 @@ def write_to_ports_conf(module):
|
|||
temp.write(_str)
|
||||
temp.seek(0)
|
||||
shutil.copyfile(temp.name, PORTS_CONF)
|
||||
except IOError, error_msg:
|
||||
except IOError:
|
||||
error_msg = get_exception()
|
||||
module.fail_json(
|
||||
msg="Failed to write to %s: %s" % (PORTS_CONF, error_msg))
|
||||
finally:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue