Fix up modules that have python24 syntax error

This commit is contained in:
Matt Martz 2015-05-08 16:36:15 -05:00 committed by Matt Clay
commit 8bd5757720
17 changed files with 104 additions and 58 deletions

View file

@ -127,13 +127,18 @@ def ensure(module, state, packages, params):
},
}
if params['accept_licenses']:
accept_licenses = ['--accept']
else:
accept_licenses = []
to_modify = filter(behaviour[state]['filter'], packages)
if to_modify:
rc, out, err = module.run_command(
[
'pkg', behaviour[state]['subcommand']
]
+ (['--accept'] if params['accept_licenses'] else [])
+ accept_licenses
+ [
'-q', '--'
] + to_modify
@ -150,12 +155,12 @@ def ensure(module, state, packages, params):
def is_installed(module, package):
rc, out, err = module.run_command(['pkg', 'list', '--', package])
return True if rc == 0 else False
return not bool(int(rc))
def is_latest(module, package):
rc, out, err = module.run_command(['pkg', 'list', '-u', '--', package])
return True if rc == 1 else False
return bool(int(rc))
from ansible.module_utils.basic import *

View file

@ -121,10 +121,15 @@ def set_publisher(module, params):
args.append('--remove-mirror=*')
args.extend(['--add-mirror=' + u for u in params['mirror']])
if params['sticky'] != None:
args.append('--sticky' if params['sticky'] else '--non-sticky')
if params['enabled'] != None:
args.append('--enable' if params['enabled'] else '--disable')
if params['sticky'] != None and params['sticky']:
args.append('--sticky')
elif params['sticky'] != None:
args.append('--non-sticky')
if params['enabled'] != None and params['enabled']:
args.append('--enable')
elif params['enabled'] != None:
args.append('--disable')
rc, out, err = module.run_command(
["pkg", "set-publisher"] + args + [name],

View file

@ -252,9 +252,8 @@ def annotate_packages(module, pkgng_path, packages, annotation):
for package in packages:
for _annotation in annotations:
annotate_c += ( 1 if operation[_annotation['operation']](
module, pkgng_path, package,
_annotation['tag'], _annotation['value']) else 0 )
if operation[_annotation['operation']](module, pkgng_path, package, _annotation['tag'], _annotation['value']):
annotate_c += 1
if annotate_c > 0:
return (True, "added %s annotations." % annotate_c)

View file

@ -422,7 +422,9 @@ def main():
if not p['package']:
module.exit_json(msg='Sync successfully finished.')
packages = p['package'].split(',') if p['package'] else []
packages = []
if p['package']:
packages.extend(p['package'].split(','))
if p['depclean']:
if packages and p['state'] not in portage_absent_states: