Port sysctl to a py3 and py24 compatible syntax (#3675)

This commit is contained in:
Michael Scherer 2016-05-17 19:20:36 +02:00 committed by Toshio Kuratomi
parent afce9e5855
commit b19a8a9b8f

View file

@ -275,7 +275,8 @@ class SysctlModule(object):
f = open(self.sysctl_file, "r")
lines = f.readlines()
f.close()
except IOError, e:
except IOError:
e = get_exception()
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
for line in lines:
@ -325,7 +326,8 @@ class SysctlModule(object):
try:
for l in self.fixed_lines:
f.write(l.strip() + "\n")
except IOError, e:
except IOError:
e = get_exception()
self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
f.flush()
f.close()