Port sysctl to a py3 and py24 compatible syntax (#3675)
This commit is contained in:
parent
afce9e5855
commit
b19a8a9b8f
1 changed files with 4 additions and 2 deletions
|
@ -275,7 +275,8 @@ class SysctlModule(object):
|
||||||
f = open(self.sysctl_file, "r")
|
f = open(self.sysctl_file, "r")
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
f.close()
|
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)))
|
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -325,7 +326,8 @@ class SysctlModule(object):
|
||||||
try:
|
try:
|
||||||
for l in self.fixed_lines:
|
for l in self.fixed_lines:
|
||||||
f.write(l.strip() + "\n")
|
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)))
|
self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, str(e)))
|
||||||
f.flush()
|
f.flush()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Reference in a new issue