From 36fa3ccf6c29bc082d170251d4bef25b24deeafa Mon Sep 17 00:00:00 2001 From: Kai de Haan Date: Thu, 12 Feb 2015 20:46:20 +0100 Subject: [PATCH] svc: Ensure python 2.5 compatibility * eg. debian lenny --- lib/ansible/modules/extras/system/svc.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) mode change 100644 => 100755 lib/ansible/modules/extras/system/svc.py diff --git a/lib/ansible/modules/extras/system/svc.py b/lib/ansible/modules/extras/system/svc.py old mode 100644 new mode 100755 index 841d6e78c9..05ef51afd9 --- a/lib/ansible/modules/extras/system/svc.py +++ b/lib/ansible/modules/extras/system/svc.py @@ -198,10 +198,12 @@ class Svc(object): self.module.fail_json(msg="failed to execute: %s" % str(e)) return (rc, out, err) - def report(self): 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 @@ -236,7 +238,7 @@ def main(): svc.enable() else: svc.disable() - except (OSError, IOError) as e: + except (OSError, IOError), e: module.fail_json(msg="Could change service link: %s" % str(e)) if state is not None and state != svc.state: @@ -253,8 +255,8 @@ def main(): open(d_file, "a").close() else: os.unlink(d_file) - except (OSError, IOError) as e: - module.fail_json(msg="Could change downed file: %s " % (str(e))) + except (OSError, IOError), e: + module.fail_json(msg="Could change downed file: %s " % (str(e))) module.exit_json(changed=changed, svc=svc.report())