mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
svc: Ensure python 2.5 compatibility
* eg. debian lenny
This commit is contained in:
12
lib/ansible/modules/extras/system/svc.py
Normal file → Executable file
12
lib/ansible/modules/extras/system/svc.py
Normal file → Executable file
@@ -198,10 +198,12 @@ class Svc(object):
|
|||||||
self.module.fail_json(msg="failed to execute: %s" % str(e))
|
self.module.fail_json(msg="failed to execute: %s" % str(e))
|
||||||
return (rc, out, err)
|
return (rc, out, err)
|
||||||
|
|
||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
self.get_status()
|
self.get_status()
|
||||||
return {k: self.__dict__[k] for k in self.report_vars}
|
states = {}
|
||||||
|
for k in self.report_vars:
|
||||||
|
states[k] = self.__dict__[k]
|
||||||
|
return states
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Main control flow
|
# Main control flow
|
||||||
@@ -236,7 +238,7 @@ def main():
|
|||||||
svc.enable()
|
svc.enable()
|
||||||
else:
|
else:
|
||||||
svc.disable()
|
svc.disable()
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError), e:
|
||||||
module.fail_json(msg="Could change service link: %s" % str(e))
|
module.fail_json(msg="Could change service link: %s" % str(e))
|
||||||
|
|
||||||
if state is not None and state != svc.state:
|
if state is not None and state != svc.state:
|
||||||
@@ -253,8 +255,8 @@ def main():
|
|||||||
open(d_file, "a").close()
|
open(d_file, "a").close()
|
||||||
else:
|
else:
|
||||||
os.unlink(d_file)
|
os.unlink(d_file)
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError), e:
|
||||||
module.fail_json(msg="Could change downed file: %s " % (str(e)))
|
module.fail_json(msg="Could change downed file: %s " % (str(e)))
|
||||||
|
|
||||||
module.exit_json(changed=changed, svc=svc.report())
|
module.exit_json(changed=changed, svc=svc.report())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user