mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
pkgng: refactor upgraded pattern matching
Implement russoz's suggestion to put all variants in the pattern.
This commit is contained in:
parent
752817cf5a
commit
d54f84f227
1 changed files with 3 additions and 4 deletions
|
@ -191,10 +191,9 @@ def upgrade_packages(module, pkgng_path, dir_arg):
|
|||
cmd += " -n"
|
||||
rc, out, err = module.run_command(cmd)
|
||||
|
||||
for action in ('upgraded', 'reinstalled',):
|
||||
match = re.search('^Number of packages to be %s: ([0-9]+)' % (action,), out, re.MULTILINE)
|
||||
if match:
|
||||
upgraded_c += int(match.group(1))
|
||||
matches = re.findall('^Number of packages to be (?:upgraded|reinstalled): ([0-9]+)', out, re.MULTILINE)
|
||||
for match in matches:
|
||||
upgraded_c += int(match)
|
||||
|
||||
if upgraded_c > 0:
|
||||
return (True, "updated %s package(s)" % upgraded_c, out, err)
|
||||
|
|
Loading…
Reference in a new issue