From 2b39879b09cc960377aa93a31dfffbace5eb5c36 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Jul 09 2020 16:30:58 +0000 Subject: [PATCH 1/3] Allow koji task URLs in download-task command --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 2d5699a..d900c8e 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6972,7 +6972,7 @@ def anon_handle_download_logs(options, session, args): def anon_handle_download_task(options, session, args): "[download] Download the output of a build task" - usage = _("usage: %prog download-task ") + usage = _("usage: %prog download-task |") parser = OptionParser(usage=get_usage_str(usage)) parser.add_option("--arch", dest="arches", metavar="ARCH", action="append", default=[], help=_("Only download packages for this arch (may be used multiple times)")) @@ -6989,11 +6989,18 @@ def anon_handle_download_task(options, session, args): (suboptions, args) = parser.parse_args(args) if len(args) == 0: - parser.error(_("Please specify a task ID")) + parser.error(_("Please specify a task ID or URL")) elif len(args) > 1: - parser.error(_("Only one task ID may be specified")) + parser.error(_("Only one task ID or URL may be specified")) + + task_arg = args.pop() + if task_arg.startswith('https://'): + # extract base_task_id from the following URL structure + # https://koji.fedoraproject.org/koji/taskinfo?taskID=28483236 + base_task_id = int(task_arg.split('=').pop()) + else: + base_task_id = int(task_arg) - base_task_id = int(args.pop()) if len(suboptions.arches) > 0: suboptions.arches = ",".join(suboptions.arches).split(",") From 62ee71dd5a0ef1ca01a7e5178d96f29c717674da Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Jul 09 2020 16:38:57 +0000 Subject: [PATCH 2/3] Update tests for download-task --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index d900c8e..fed6ebc 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6972,7 +6972,7 @@ def anon_handle_download_logs(options, session, args): def anon_handle_download_task(options, session, args): "[download] Download the output of a build task" - usage = _("usage: %prog download-task |") + usage = _("usage: %prog download-task ") parser = OptionParser(usage=get_usage_str(usage)) parser.add_option("--arch", dest="arches", metavar="ARCH", action="append", default=[], help=_("Only download packages for this arch (may be used multiple times)")) diff --git a/tests/test_cli/test_download_task.py b/tests/test_cli/test_download_task.py index 3918454..43ee8b5 100644 --- a/tests/test_cli/test_download_task.py +++ b/tests/test_cli/test_download_task.py @@ -329,7 +329,7 @@ class TestDownloadTask(utils.CliTestCase): anon_handle_download_task(self.options, self.session, args) self.assertExitCode(ex, 0) actual = self.stdout.getvalue() - expected = """Usage: %s download-task + expected = """Usage: %s download-task (Specify the --help global option for a list of other help options) Options: @@ -359,12 +359,12 @@ Options: expected = '' self.assertMultiLineEqual(actual, expected) actual = self.stderr.getvalue() - expected = """Usage: %s download-task + expected = """Usage: %s download-task (Specify the --help global option for a list of other help options) -%s: error: Please specify a task ID +%s: error: Please specify a task ID or URL """ % (progname, progname) - self.assertEqual(actual, expected) + self.assertMultiLineEqual(actual, expected) def test_handle_download_multi_task_id(self): args = ["123", "456"] @@ -378,9 +378,9 @@ Options: expected = '' self.assertMultiLineEqual(actual, expected) actual = self.stderr.getvalue() - expected = """Usage: %s download-task + expected = """Usage: %s download-task (Specify the --help global option for a list of other help options) -%s: error: Only one task ID may be specified +%s: error: Only one task ID or URL may be specified """ % (progname, progname) - self.assertEqual(actual, expected) + self.assertMultiLineEqual(actual, expected) From fb24fa47f4098ca68b22c794ab32cad561042752 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Jul 09 2020 16:39:02 +0000 Subject: [PATCH 3/3] Change URL check to pass http:// in addition to https:// --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index fed6ebc..1692cde 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -6994,7 +6994,7 @@ def anon_handle_download_task(options, session, args): parser.error(_("Only one task ID or URL may be specified")) task_arg = args.pop() - if task_arg.startswith('https://'): + if "?taskID=" in task_arg: # extract base_task_id from the following URL structure # https://koji.fedoraproject.org/koji/taskinfo?taskID=28483236 base_task_id = int(task_arg.split('=').pop())