mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-12 11:24:00 -07:00
Bulk autopep8 (modules)
As agreed in 2017-12-07 Core meeting bulk fix pep8 issues Generated using: autopep8 1.3.3 (pycodestyle: 2.3.1) autopep8 -r --max-line-length 160 --in-place --ignore E305,E402,E722,E741 lib/ansible/modules Manually fix issues that autopep8 has introduced
This commit is contained in:
parent
d13d7e9404
commit
c57a7f05e1
314 changed files with 3462 additions and 3383 deletions
|
@ -69,6 +69,7 @@ EXAMPLES = '''
|
|||
import os
|
||||
import pipes
|
||||
|
||||
|
||||
def package_installed(module, name):
|
||||
cmd = ['pkginfo']
|
||||
cmd.append('-q')
|
||||
|
@ -79,11 +80,12 @@ def package_installed(module, name):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
def package_latest(module, name, site):
|
||||
# Only supports one package
|
||||
cmd = [ 'pkgutil', '-U', '--single', '-c' ]
|
||||
cmd = ['pkgutil', '-U', '--single', '-c']
|
||||
if site is not None:
|
||||
cmd += [ '-t', site]
|
||||
cmd += ['-t', site]
|
||||
cmd.append(name)
|
||||
rc, out, err = run_command(module, cmd)
|
||||
# replace | tail -1 |grep -v SAME
|
||||
|
@ -91,45 +93,50 @@ def package_latest(module, name, site):
|
|||
# at the end of the list
|
||||
return 'SAME' in out.split('\n')[-2]
|
||||
|
||||
|
||||
def run_command(module, cmd, **kwargs):
|
||||
progname = cmd[0]
|
||||
cmd[0] = module.get_bin_path(progname, True, ['/opt/csw/bin'])
|
||||
return module.run_command(cmd, **kwargs)
|
||||
|
||||
|
||||
def package_install(module, state, name, site, update_catalog):
|
||||
cmd = [ 'pkgutil', '-iy' ]
|
||||
cmd = ['pkgutil', '-iy']
|
||||
if update_catalog:
|
||||
cmd += [ '-U' ]
|
||||
cmd += ['-U']
|
||||
if site is not None:
|
||||
cmd += [ '-t', site ]
|
||||
cmd += ['-t', site]
|
||||
if state == 'latest':
|
||||
cmd += [ '-f' ]
|
||||
cmd += ['-f']
|
||||
cmd.append(name)
|
||||
(rc, out, err) = run_command(module, cmd)
|
||||
return (rc, out, err)
|
||||
|
||||
|
||||
def package_upgrade(module, name, site, update_catalog):
|
||||
cmd = [ 'pkgutil', '-ufy' ]
|
||||
cmd = ['pkgutil', '-ufy']
|
||||
if update_catalog:
|
||||
cmd += [ '-U' ]
|
||||
cmd += ['-U']
|
||||
if site is not None:
|
||||
cmd += [ '-t', site ]
|
||||
cmd += ['-t', site]
|
||||
cmd.append(name)
|
||||
(rc, out, err) = run_command(module, cmd)
|
||||
return (rc, out, err)
|
||||
|
||||
|
||||
def package_uninstall(module, name):
|
||||
cmd = [ 'pkgutil', '-ry', name]
|
||||
cmd = ['pkgutil', '-ry', name]
|
||||
(rc, out, err) = run_command(module, cmd)
|
||||
return (rc, out, err)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
name = dict(required = True),
|
||||
state = dict(required = True, choices=['present', 'absent','latest']),
|
||||
site = dict(default = None),
|
||||
update_catalog = dict(required = False, default = False, type='bool'),
|
||||
argument_spec=dict(
|
||||
name=dict(required=True),
|
||||
state=dict(required=True, choices=['present', 'absent', 'latest']),
|
||||
site=dict(default=None),
|
||||
update_catalog=dict(required=False, default=False, type='bool'),
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue