1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

@ -492,7 +492,7 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated
if package_version_compare(pkg_version, installed_version) == 0:
# Does not need to down-/upgrade, move on to next package
continue
except Exception, e:
except Exception:
# Must not be installed, continue with installation
pass
# Check if package is installable

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)

View file

@ -475,7 +475,8 @@ def main():
if pool != '^$':
try:
result = rhn.update_subscriptions(pool)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failed to update subscriptions for '%s': %s" % (server_hostname, e))
else:
module.exit_json(**result)
@ -488,7 +489,8 @@ def main():
rhn.register(username, password, autosubscribe, activationkey, org_id,
consumer_type, consumer_name, consumer_id)
subscribed_pool_ids = rhn.subscribe(pool)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failed to register with '%s': %s" % (server_hostname, e))
else:
module.exit_json(changed=True,
@ -502,7 +504,8 @@ def main():
try:
rhn.unsubscribe()
rhn.unregister()
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failed to unregister: %s" % e)
else:
module.exit_json(changed=True, msg="System successfully unregistered from %s." % server_hostname)

View file

@ -120,7 +120,7 @@ try:
import up2date_client
import up2date_client.config
HAS_UP2DATE_CLIENT = True
except ImportError, e:
except ImportError:
HAS_UP2DATE_CLIENT = False
# INSERT REDHAT SNIPPETS
@ -387,7 +387,8 @@ def main():
rhn.enable()
rhn.register(module.params['enable_eus'] == True, activationkey, profilename, sslcacert, systemorgid)
rhn.subscribe(channels)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failed to register with '%s': %s" % (rhn.hostname, e))
module.exit_json(changed=True, msg="System successfully registered to '%s'." % rhn.hostname)
@ -399,7 +400,8 @@ def main():
else:
try:
rhn.unregister()
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failed to unregister: %s" % e)
module.exit_json(changed=True, msg="System successfully unregistered from %s." % rhn.hostname)

View file

@ -245,7 +245,8 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, di
pkgs = e + m
if not pkgs and not is_pkg:
pkgs.extend(my.returnInstalledPackagesByDep(pkgspec))
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure talking to yum: %s" % e)
return [ po_to_nevra(p) for p in pkgs ]
@ -301,7 +302,8 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, di
pkgs = e + m
if not pkgs:
pkgs.extend(my.returnPackagesByDep(pkgspec))
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure talking to yum: %s" % e)
return [ po_to_nevra(p) for p in pkgs ]
@ -348,7 +350,8 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_r
e,m,u = my.pkgSack.matchPackageNames([pkgspec])
pkgs = e + m
updates = my.doPackageLists(pkgnarrow='updates').updates
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure talking to yum: %s" % e)
for pkg in pkgs:
@ -399,7 +402,8 @@ def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=None,
e,m,u = my.rpmdb.matchPackageNames([req_spec])
pkgs.extend(e)
pkgs.extend(m)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure talking to yum: %s" % e)
return set([ po_to_nevra(p) for p in pkgs ])
@ -588,7 +592,8 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
f.write(data)
data = rsp.read(BUFSIZE)
f.close()
except Exception, e:
except Exception:
e = get_exception()
shutil.rmtree(tempdir)
module.fail_json(msg="Failure downloading %s, %s" % (spec, e))
@ -664,7 +669,8 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
# Remove rpms downloaded for EL5 via url
try:
shutil.rmtree(tempdir)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
module.exit_json(changed=True, results=res['results'], changes=dict(installed=pkgs))
@ -704,7 +710,8 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
# Remove rpms downloaded for EL5 via url
try:
shutil.rmtree(tempdir)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Failure deleting temp directory %s, %s" % (tempdir, e))
return res
@ -959,9 +966,11 @@ def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
rid = my.repos.getRepo(i)
a = rid.repoXML.repoid
current_repos = new_repos
except yum.Errors.YumBaseError, e:
except yum.Errors.YumBaseError:
e = get_exception()
module.fail_json(msg="Error setting/accessing repos: %s" % (e))
except yum.Errors.YumBaseError, e:
except yum.Errors.YumBaseError:
e = get_exception()
module.fail_json(msg="Error accessing repos: %s" % e)
if state in ['installed', 'present']:
if disable_gpg_check: