From 65a3dc0953ad0ff5001484891c74a8c7a3d1cba2 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Nov 28 2018 20:25:57 +0000 Subject: move inner function out of except clause --- diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index ce04706..1f677d2 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -281,6 +281,15 @@ def watch_tasks(session, tasklist, quiet=False, poll_interval=60, ki_handler=Non return if not quiet: print("Watching tasks (this may be safely interrupted)...") + if ki_handler is None: + 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))) sys.stdout.flush() rv = 0 try: @@ -319,15 +328,6 @@ def watch_tasks(session, tasklist, quiet=False, poll_interval=60, ki_handler=Non except KeyboardInterrupt: if tasks: progname = os.path.basename(sys.argv[0]) or 'koji' - if ki_handler is None: - 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, quiet) raise return rv