From 9beaac9561eebdfceada0fef0e442ea5c85a43e8 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jul 02 2020 12:23:52 +0000 Subject: PR#2346: cli: --wait for download-task Merges #2346 https://pagure.io/koji/pull-request/2346 Fixes: #2052 https://pagure.io/koji/issue/2052 [RFE] make "koji download-task" wait for unfinished tasks to complete --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 06c4b69..2d5699a 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6982,6 +6982,8 @@ def anon_handle_download_task(options, session, args): help=_("URL under which Koji files are accessible")) parser.add_option("--noprogress", action="store_true", help=_("Do not display progress meter")) + parser.add_option("--wait", action="store_true", + help=_("Wait for running tasks to finish")) parser.add_option("-q", "--quiet", action="store_true", help=_("Suppress output"), default=options.quiet) @@ -7003,6 +7005,13 @@ def anon_handle_download_task(options, session, args): if not base_task: error(_('No such task: #%i') % base_task_id) + if suboptions.wait and base_task['state'] not in ( + koji.TASK_STATES['CLOSED'], + koji.TASK_STATES['CANCELED'], + koji.TASK_STATES['FAILED']): + watch_tasks(session, [base_task_id], quiet=suboptions.quiet, + poll_interval=options.poll_interval) + def check_downloadable(task): return task["method"] == "buildArch" diff --git a/tests/test_cli/test_download_task.py b/tests/test_cli/test_download_task.py index e14926a..3918454 100644 --- a/tests/test_cli/test_download_task.py +++ b/tests/test_cli/test_download_task.py @@ -339,6 +339,7 @@ Options: --logs Also download build logs --topurl=URL URL under which Koji files are accessible --noprogress Do not display progress meter + --wait Wait for running tasks to finish -q, --quiet Suppress output """ % progname self.assertMultiLineEqual(actual, expected)