Pylint fixes for packaging (#23553)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/24144/head
Abhijeet Kasurde 8 years ago committed by Matt Martz
parent 040fb4435a
commit 8ba069315e

@ -3,7 +3,7 @@
# (c) 2015, Kevin Brebanov <https://github.com/kbrebanov> # (c) 2015, Kevin Brebanov <https://github.com/kbrebanov>
# Based on pacman (Afterburn <http://github.com/afterburn>, Aaron Bull Schaefer <aaron@elasticdog.com>) # Based on pacman (Afterburn <http://github.com/afterburn>, Aaron Bull Schaefer <aaron@elasticdog.com>)
# and apt (Matthew Williams <matthew@flowroute.com>>) modules. # and apt (Matthew Williams <matthew@flowroute.com>) modules.
# #
# This module is free software: you can redistribute it and/or modify # This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -114,8 +114,10 @@ EXAMPLES = '''
update_cache: yes update_cache: yes
''' '''
import os
import re import re
# Import module snippets.
from ansible.module_utils.basic import AnsibleModule
def update_package_db(module): def update_package_db(module):
cmd = "%s update" % (APK_PATH) cmd = "%s update" % (APK_PATH)
@ -230,15 +232,15 @@ def remove_packages(module, names):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
state = dict(default='present', choices=['present', 'installed', 'absent', 'removed', 'latest']), state=dict(default='present', choices=['present', 'installed', 'absent', 'removed', 'latest']),
name = dict(type='list'), name=dict(type='list'),
update_cache = dict(default='no', type='bool'), update_cache=dict(default='no', type='bool'),
upgrade = dict(default='no', type='bool'), upgrade=dict(default='no', type='bool'),
), ),
required_one_of = [['name', 'update_cache', 'upgrade']], required_one_of=[['name', 'update_cache', 'upgrade']],
mutually_exclusive = [['name', 'upgrade']], mutually_exclusive=[['name', 'upgrade']],
supports_check_mode = True supports_check_mode=True
) )
# Set LANG env since we parse stdout # Set LANG env since we parse stdout
@ -268,7 +270,6 @@ def main():
elif p['state'] == 'absent': elif p['state'] == 'absent':
remove_packages(module, p['name']) remove_packages(module, p['name'])
# Import module snippets.
from ansible.module_utils.basic import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

@ -245,14 +245,14 @@ from ansible.module_utils.urls import fetch_url
# APT related constants # APT related constants
APT_ENV_VARS = dict( APT_ENV_VARS = dict(
DEBIAN_FRONTEND = 'noninteractive', DEBIAN_FRONTEND='noninteractive',
DEBIAN_PRIORITY = 'critical', DEBIAN_PRIORITY='critical',
# We screenscrape apt-get and aptitude output for information so we need # We screenscrape apt-get and aptitude output for information so we need
# to make sure we use the C locale when running commands # to make sure we use the C locale when running commands
LANG = 'C', LANG='C',
LC_ALL = 'C', LC_ALL='C',
LC_MESSAGES = 'C', LC_MESSAGES='C',
LC_CTYPE = 'C', LC_CTYPE='C',
) )
DPKG_OPTIONS = 'force-confdef,force-confold' DPKG_OPTIONS = 'force-confdef,force-confold'
@ -543,7 +543,7 @@ def get_field_of_deb(m, deb_file, field="Version"):
def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated, dpkg_options): def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated, dpkg_options):
changed=False changed = False
deps_to_install = [] deps_to_install = []
pkgs_to_install = [] pkgs_to_install = []
for deb_file in debs.split(','): for deb_file in debs.split(','):
@ -614,7 +614,7 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated
else: else:
m.fail_json(msg="%s failed" % cmd, stdout=stdout, stderr=stderr) m.fail_json(msg="%s failed" % cmd, stdout=stdout, stderr=stderr)
else: else:
m.exit_json(changed=changed, stdout=retvals.get('stdout',''), stderr=retvals.get('stderr',''), diff=retvals.get('diff', '')) m.exit_json(changed=changed, stdout=retvals.get('stdout', ''), stderr=retvals.get('stderr', ''), diff=retvals.get('diff', ''))
def remove(m, pkgspec, cache, purge=False, force=False, def remove(m, pkgspec, cache, purge=False, force=False,
@ -651,7 +651,7 @@ def remove(m, pkgspec, cache, purge=False, force=False,
else: else:
check_arg = '' check_arg = ''
cmd = "%s -q -y %s %s %s %s %s remove %s" % (APT_GET_CMD, dpkg_options, purge, force_yes ,autoremove, check_arg, packages) cmd = "%s -q -y %s %s %s %s %s remove %s" % (APT_GET_CMD, dpkg_options, purge, force_yes, autoremove, check_arg, packages)
rc, out, err = m.run_command(cmd) rc, out, err = m.run_command(cmd)
if m._diff: if m._diff:
@ -697,7 +697,7 @@ def upgrade(m, mode="yes", force=False, default_release=None,
apt_cmd_path = m.get_bin_path(apt_cmd, required=True) apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
cmd = '%s -y %s %s %s %s' % (apt_cmd_path, dpkg_options, cmd = '%s -y %s %s %s %s' % (apt_cmd_path, dpkg_options,
force_yes, check_arg, upgrade_command) force_yes, check_arg, upgrade_command)
if default_release: if default_release:
cmd += " -t '%s'" % (default_release,) cmd += " -t '%s'" % (default_release,)
@ -798,25 +798,25 @@ def get_cache(module):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
state = dict(default='present', choices=['installed', 'latest', 'removed', 'absent', 'present', 'build-dep']), state=dict(default='present', choices=['installed', 'latest', 'removed', 'absent', 'present', 'build-dep']),
update_cache = dict(aliases=['update-cache'], type='bool'), update_cache=dict(aliases=['update-cache'], type='bool'),
cache_valid_time = dict(type='int', default=0), cache_valid_time=dict(type='int', default=0),
purge = dict(default=False, type='bool'), purge=dict(default=False, type='bool'),
package = dict(default=None, aliases=['pkg', 'name'], type='list'), package=dict(default=None, aliases=['pkg', 'name'], type='list'),
deb = dict(default=None, type='path'), deb=dict(default=None, type='path'),
default_release = dict(default=None, aliases=['default-release']), default_release=dict(default=None, aliases=['default-release']),
install_recommends = dict(default=None, aliases=['install-recommends'], type='bool'), install_recommends=dict(default=None, aliases=['install-recommends'], type='bool'),
force = dict(default='no', type='bool'), force=dict(default='no', type='bool'),
upgrade = dict(choices=['no', 'yes', 'safe', 'full', 'dist']), upgrade=dict(choices=['no', 'yes', 'safe', 'full', 'dist']),
dpkg_options = dict(default=DPKG_OPTIONS), dpkg_options=dict(default=DPKG_OPTIONS),
autoremove = dict(type='bool', aliases=['autoclean']), autoremove=dict(type='bool', aliases=['autoclean']),
only_upgrade = dict(type='bool', default=False), only_upgrade=dict(type='bool', default=False),
allow_unauthenticated = dict(default='no', aliases=['allow-unauthenticated'], type='bool'), allow_unauthenticated=dict(default='no', aliases=['allow-unauthenticated'], type='bool'),
), ),
mutually_exclusive = [['package', 'upgrade', 'deb']], mutually_exclusive=[['package', 'upgrade', 'deb']],
required_one_of = [['package', 'upgrade', 'update_cache', 'deb', 'autoremove']], required_one_of=[['package', 'upgrade', 'update_cache', 'deb', 'autoremove']],
supports_check_mode = True supports_check_mode=True
) )
module.run_command_environ_update = APT_ENV_VARS module.run_command_environ_update = APT_ENV_VARS
@ -846,7 +846,7 @@ def main():
if p['upgrade'] == 'no': if p['upgrade'] == 'no':
p['upgrade'] = None p['upgrade'] = None
if not APTITUDE_CMD and p.get('upgrade', None) in [ 'full', 'safe', 'yes' ]: if not APTITUDE_CMD and p.get('upgrade', None) in ['full', 'safe', 'yes']:
module.fail_json(msg="Could not find aptitude. Please ensure it is installed.") module.fail_json(msg="Could not find aptitude. Please ensure it is installed.")
updated_cache = False updated_cache = False

@ -51,9 +51,9 @@ EXAMPLES = '''
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
name = dict(required=True), name=dict(required=True),
selection = dict(choices=['install', 'hold', 'deinstall', 'purge']) selection=dict(choices=['install', 'hold', 'deinstall', 'purge'])
), ),
supports_check_mode=True, supports_check_mode=True,
) )

Loading…
Cancel
Save