From c9fa3d87118f0b91d636597a5b95ce8f227f2634 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jun 26 2020 13:31:29 +0000 Subject: cli: --wait for download-task If task is not finished yet, wait for it and download output then. Fixes: https://pagure.io/koji/issue/2052 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index e5594f8..e51ffbc 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6978,6 +6978,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) @@ -6999,6 +7001,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)