mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Fix up modules that have python24 syntax error
This commit is contained in:
parent
a03da8d592
commit
8bd5757720
17 changed files with 104 additions and 58 deletions
|
@ -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 *
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue