Skip to content

Commit e7e8106

Browse files
authored
Merge pull request smilejay#3 from Henocks/patch-1
Visual Update rpmdb.py
2 parents d169bfe + 60e47f9 commit e7e8106

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

py2016/rpmdb.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def check_db(module, timeout=10):
7777
elapsed_time = 0
7878
cmd = '%s -qa &> %s' % (RPMBIN, logfile)
7979
child = subprocess.Popen(cmd, shell=True)
80+
8081
while elapsed_time <= timeout:
8182
child_ret = child.poll()
8283
if child_ret is None: # child still running
@@ -112,8 +113,8 @@ def main():
112113
# defining module
113114
module = AnsibleModule(
114115
argument_spec=dict(
115-
action=dict(required=False, default='check', choices=['check', 'rebuild']),
116-
timeout=dict(required=False, default=10, type='int')
116+
action = dict(required=False, default='check', choices=['check', 'rebuild']),
117+
timeout = dict(required=False, default=10, type='int')
117118
)
118119
)
119120

@@ -126,13 +127,14 @@ def main():
126127
if action == 'check':
127128
rc = check_db(module, timeout)
128129
if rc == 1:
129-
module.fail_json(msg='Error when running cmd: %s' % check_cmd)
130+
module.fail_json(msg='Error when running cmd: %s' % (check_cmd))
130131
elif rc == 2:
131132
module.fail_json(msg='return code error. cmd: %s' % (check_cmd))
132133
elif rc == 3:
133-
module.fail_json(msg='Timeout %d s. cmd: %s' % (timeout, check_cmd))
134+
module.fail_json(msg='Timeout %d s. cmd: %s' % (timeout, check_cmd))
134135
elif rc == 0:
135136
msg = 'OK. cmd: %s' % check_cmd
137+
136138
elif action == 'rebuild':
137139
rc = check_db(module, timeout)
138140
if rc != 0:
@@ -144,9 +146,9 @@ def main():
144146
module.fail_json(msg=msg)
145147

146148
module.exit_json(
147-
changed=changed,
148-
action=action,
149-
msg=msg
149+
changed = changed,
150+
action = action,
151+
msg = msg
150152
)
151153

152154
# this is magic, see lib/ansible/executor/module_common.py

0 commit comments

Comments
 (0)