Pylint fixes for yum module

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-04-10 17:11:12 +05:30 committed by Matt Clay
parent db6d818865
commit ba3295dd3f

View file

@ -772,10 +772,10 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i
lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C')
rc, out, err = module.run_command(cmd, environ_update=lang_env)
if (rc == 1):
if rc == 1:
for spec in items:
# Fail on invalid urls:
if ('://' in spec and ('No package %s available.' % spec in out or 'Cannot open: %s. Skipping.' % spec in err)):
if '://' in spec and ('No package %s available.' % spec in out or 'Cannot open: %s. Skipping.' % spec in err):
module.fail_json(msg='Package at %s could not be installed' % spec, rc=1, changed=False)
if (rc != 0 and 'Nothing to do' in err) or 'Nothing to do' in out:
# avoid failing in the 'Nothing To Do' case
@ -1163,8 +1163,8 @@ def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo,
res = latest(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos, installroot=installroot)
else:
# should be caught by AnsibleModule argument_spec
module.fail_json(msg="we should never get here unless this all"
" failed", changed=False, results='', errors='unexpected state')
module.fail_json(msg="we should never get here unless this all failed",
changed=False, results='', errors='unexpected state')
return res
@ -1181,13 +1181,14 @@ def main():
# list=repos
# list=pkgspec
module = AnsibleModule(
argument_spec=dict(
name=dict(aliases=['pkg'], type="list"),
exclude=dict(required=False, default=None),
# removed==absent, installed==present, these are accepted as aliases
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
state=dict(default='installed', choices=['absent', 'present',
'installed', 'removed',
'latest']),
enablerepo=dict(),
disablerepo=dict(),
list=dict(),
@ -1254,8 +1255,8 @@ def main():
disable_gpg_check = params['disable_gpg_check']
skip_broken = params['skip_broken']
results = ensure(module, state, pkg, params['conf_file'], enablerepo,
disablerepo, disable_gpg_check, exclude, repoquery, skip_broken,
params['installroot'])
disablerepo, disable_gpg_check, exclude, repoquery,
skip_broken, params['installroot'])
if repoquery:
results['msg'] = '%s %s' % (results.get('msg', ''),
'Warning: Due to potential bad behaviour with rhnplugin and certificates, used slower repoquery calls instead of Yum API.')