mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
pkgng: refactor upgraded pattern matching
Implement russoz's suggestion to put all variants in the pattern.
This commit is contained in:
@@ -191,10 +191,9 @@ def upgrade_packages(module, pkgng_path, dir_arg):
|
|||||||
cmd += " -n"
|
cmd += " -n"
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
|
|
||||||
for action in ('upgraded', 'reinstalled',):
|
matches = re.findall('^Number of packages to be (?:upgraded|reinstalled): ([0-9]+)', out, re.MULTILINE)
|
||||||
match = re.search('^Number of packages to be %s: ([0-9]+)' % (action,), out, re.MULTILINE)
|
for match in matches:
|
||||||
if match:
|
upgraded_c += int(match)
|
||||||
upgraded_c += int(match.group(1))
|
|
||||||
|
|
||||||
if upgraded_c > 0:
|
if upgraded_c > 0:
|
||||||
return (True, "updated %s package(s)" % upgraded_c, out, err)
|
return (True, "updated %s package(s)" % upgraded_c, out, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user