mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fixing identation, removing some unnecessary conditionals.
This commit is contained in:
parent
727964ab55
commit
9b0f5dd212
1 changed files with 35 additions and 38 deletions
|
@ -1524,48 +1524,45 @@ def installed(
|
|||
|
||||
# check that the hold function is available
|
||||
if 'pkg.hold' in __salt__ and 'hold' in kwargs:
|
||||
try:
|
||||
action = 'pkg.hold' if kwargs['hold'] else 'pkg.unhold'
|
||||
hold_ret = __salt__[action](
|
||||
name=name, pkgs=pkgs, sources=sources
|
||||
)
|
||||
except (CommandExecutionError, SaltInvocationError) as exc:
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': str(exc)}
|
||||
try:
|
||||
action = 'pkg.hold' if kwargs['hold'] else 'pkg.unhold'
|
||||
hold_ret = __salt__[action](
|
||||
name=name, pkgs=pkgs, sources=sources
|
||||
)
|
||||
except (CommandExecutionError, SaltInvocationError) as exc:
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': str(exc)}
|
||||
|
||||
if 'result' in hold_ret and not hold_ret['result']:
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': 'An error was encountered while '
|
||||
'holding/unholding package(s): {0}'
|
||||
.format(hold_ret['comment'])}
|
||||
else:
|
||||
modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if hold_ret[x]['changes']]
|
||||
not_modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['changes']
|
||||
and hold_ret[x]['result']]
|
||||
failed_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['result']]
|
||||
if 'result' in hold_ret and not hold_ret['result']:
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': 'An error was encountered while '
|
||||
'holding/unholding package(s): {0}'
|
||||
.format(hold_ret['comment'])}
|
||||
else:
|
||||
modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if hold_ret[x]['changes']]
|
||||
not_modified_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['changes']
|
||||
and hold_ret[x]['result']]
|
||||
failed_hold = [hold_ret[x] for x in hold_ret
|
||||
if not hold_ret[x]['result']]
|
||||
|
||||
if modified_hold:
|
||||
for i in modified_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
result['changes'][i['name']] = i['changes']
|
||||
for i in modified_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
result['changes'][i['name']] = i['changes']
|
||||
|
||||
if not_modified_hold:
|
||||
for i in not_modified_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
for i in not_modified_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
|
||||
if failed_hold:
|
||||
for i in failed_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
for i in failed_hold:
|
||||
result['comment'] += '.\n{0}'.format(i['comment'])
|
||||
result['result'] = i['result']
|
||||
return result
|
||||
|
||||
if to_unpurge and 'lowpkg.unpurge' not in __salt__:
|
||||
|
|
Loading…
Add table
Reference in a new issue