Convert packaging/* to py3/py2.4 syntax (#3702)

This commit is contained in:
Michael Scherer 2016-05-20 16:48:10 +02:00 committed by Matt Clay
parent cd09aab9b4
commit b8175f70ce
5 changed files with 37 additions and 20 deletions

View file

@ -273,7 +273,8 @@ class SourcesList(object):
try:
f.write(line)
except IOError, err:
except IOError:
err = get_exception()
self.module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err)))
self.module.atomic_move(tmp_path, filename)
@ -451,7 +452,7 @@ def main():
argument_spec=dict(
repo=dict(required=True),
state=dict(choices=['present', 'absent'], default='present'),
mode=dict(required=False, default=0644),
mode=dict(required=False, default=int('0644',8)),
update_cache = dict(aliases=['update-cache'], type='bool', default='yes'),
filename=dict(required=False, default=None),
# this should not be needed, but exists as a failsafe
@ -488,7 +489,8 @@ def main():
sourceslist.add_source(repo)
elif state == 'absent':
sourceslist.remove_source(repo)
except InvalidSource, err:
except InvalidSource:
err = get_exception()
module.fail_json(msg='Invalid repository string: %s' % unicode(err))
sources_after = sourceslist.dump()
@ -510,7 +512,8 @@ def main():
if update_cache:
cache = apt.Cache()
cache.update()
except OSError, err:
except OSError:
err = get_exception()
module.fail_json(msg=unicode(err))
module.exit_json(changed=changed, repo=repo, state=state, diff=diff)