Convert the network subfolder to py3/py2.4 syntax (#3690)

This commit is contained in:
Michael Scherer 2016-05-18 18:08:30 +02:00 committed by Matt Clay
commit c0217e14a7
20 changed files with 90 additions and 47 deletions

View file

@ -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()

View file

@ -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: