diff options
author | Chris Weber <chris.l.weber@gmail.com> | 2016-06-03 06:23:55 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-06-03 06:23:55 -0700 |
commit | 9e277aabb033b3ec823b4a2db7c0f7e315eaaf0b (patch) | |
tree | 47632394a6ce1fef4f71687f49a1a8dd6c9e9db2 /system/svc.py | |
parent | 3444cd1813612fb230425ef41f111dc3a5f38b4e (diff) | |
download | ansible-modules-extras-9e277aabb033b3ec823b4a2db7c0f7e315eaaf0b.tar.gz |
Fixed modules/system py files for 2.4 to 3.5 exceptions (#2367)
Diffstat (limited to 'system/svc.py')
-rwxr-xr-x | system/svc.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/system/svc.py b/system/svc.py index 6cc8c1d2..e82b0591 100755 --- a/system/svc.py +++ b/system/svc.py @@ -87,6 +87,8 @@ EXAMPLES = ''' import platform import shlex +from ansible.module_utils.pycompat24 import get_exception +from ansible.module_utils.basic import * def _load_dist_subclass(cls, *args, **kwargs): ''' @@ -152,7 +154,8 @@ class Svc(object): if os.path.exists(self.src_full): try: os.symlink(self.src_full, self.svc_full) - except OSError, e: + except OSError: + e = get_exception() self.module.fail_json(path=self.src_full, msg='Error while linking: %s' % str(e)) else: self.module.fail_json(msg="Could not find source for service to enable (%s)." % self.src_full) @@ -160,7 +163,8 @@ class Svc(object): def disable(self): try: os.unlink(self.svc_full) - except OSError, e: + except OSError: + e = get_exception() self.module.fail_json(path=self.svc_full, msg='Error while unlinking: %s' % str(e)) self.execute_command([self.svc_cmd,'-dx',self.src_full]) @@ -221,7 +225,8 @@ class Svc(object): def execute_command(self, cmd): try: (rc, out, err) = self.module.run_command(' '.join(cmd)) - except Exception, e: + except Exception: + e = get_exception() self.module.fail_json(msg="failed to execute: %s" % str(e)) return (rc, out, err) @@ -267,7 +272,8 @@ def main(): svc.enable() else: svc.disable() - except (OSError, IOError), e: + except (OSError, IOError): + e = get_exception() module.fail_json(msg="Could change service link: %s" % str(e)) if state is not None and state != svc.state: @@ -284,13 +290,13 @@ def main(): open(d_file, "a").close() else: os.unlink(d_file) - except (OSError, IOError), e: + except (OSError, IOError): + e = get_exception() module.fail_json(msg="Could change downed file: %s " % (str(e))) module.exit_json(changed=changed, svc=svc.report()) -# this is magic, not normal python include -from ansible.module_utils.basic import * + main() |