move quiet option into ki_handler

This commit is contained in:
Yuming Zhu 2018-06-25 19:44:20 +08:00 committed by Mike McLean
parent 30ed89e485
commit 9a0d735d40
2 changed files with 8 additions and 7 deletions

View file

@ -317,17 +317,18 @@ def watch_tasks(session, tasklist, quiet=False, poll_interval=60, ki_handler=Non
sys.stdout.flush()
time.sleep(poll_interval)
except KeyboardInterrupt:
if tasks and not quiet:
if tasks:
progname = os.path.basename(sys.argv[0]) or 'koji'
if ki_handler is None:
def ki_handler(progname, tasks):
tlist = ['%s: %s' % (t.str(), t.display_state(t.info))
for t in tasks.values() if not t.is_done()]
print(
def ki_handler(progname, tasks, quiet):
if not quiet:
tlist = ['%s: %s' % (t.str(), t.display_state(t.info))
for t in tasks.values() if not t.is_done()]
print(
"""Tasks still running. You can continue to watch with the '%s watch-task' command.
Running Tasks:
%s""" % (progname, '\n'.join(tlist)))
ki_handler(progname, tasks)
ki_handler(progname, tasks, quiet)
raise
return rv

View file

@ -131,7 +131,7 @@ Running Tasks:
self.session.load_calls(cdata)
sleep.side_effect = [None] * 10 + [KeyboardInterrupt]
def customized_handler(progname, tasks):
def customized_handler(progname, tasks, quiet):
print('some output')
with self.assertRaises(KeyboardInterrupt):