|
|
3ab372 |
From 54b7c5f91b4ad1db1f716f25cc7973ec7542f0d4 Mon Sep 17 00:00:00 2001
|
|
|
3ab372 |
From: Jakub Kadlcik <frostyx@email.cz>
|
|
|
3ab372 |
Date: Tue, 12 Oct 2021 12:54:05 +0200
|
|
|
3ab372 |
Subject: [PATCH] copr: migrate all calls to APIv3
|
|
|
3ab372 |
|
|
|
3ab372 |
In the latest Copr release we dropped all APIv1 code from frontend.
|
|
|
3ab372 |
https://docs.pagure.org/copr.copr/release-notes/2021-10-01.html
|
|
|
3ab372 |
|
|
|
3ab372 |
Unfortunatelly we frogot to migrate DNF copr plugin to APIv3 and
|
|
|
3ab372 |
therefore the following commands started failing with 404.
|
|
|
3ab372 |
|
|
|
3ab372 |
dnf copr search tests
|
|
|
3ab372 |
dnf copr list --available-by-user frostyx
|
|
|
3ab372 |
---
|
|
|
3ab372 |
plugins/copr.py | 40 +++++++++++++++++-----------------------
|
|
|
3ab372 |
1 file changed, 17 insertions(+), 23 deletions(-)
|
|
|
3ab372 |
|
|
|
3ab372 |
diff --git a/plugins/copr.py b/plugins/copr.py
|
|
|
3ab372 |
index 8841f03..7fc6c6f 100644
|
|
|
3ab372 |
--- a/plugins/copr.py
|
|
|
3ab372 |
+++ b/plugins/copr.py
|
|
|
3ab372 |
@@ -355,51 +355,45 @@ Bugzilla. In case of problems, contact the owner of this repository.
|
|
|
3ab372 |
"Re-enable the project to fix this."))
|
|
|
3ab372 |
|
|
|
3ab372 |
def _list_user_projects(self, user_name):
|
|
|
3ab372 |
- # http://copr.fedorainfracloud.org/api/coprs/ignatenkobrain/
|
|
|
3ab372 |
- api_path = "/api/coprs/{}/".format(user_name)
|
|
|
3ab372 |
- res = self.base.urlopen(self.copr_url + api_path, mode='w+')
|
|
|
3ab372 |
+ # https://copr.fedorainfracloud.org/api_3/project/list?ownername=ignatenkobrain
|
|
|
3ab372 |
+ api_path = "/api_3/project/list?ownername={0}".format(user_name)
|
|
|
3ab372 |
+ url = self.copr_url + api_path
|
|
|
3ab372 |
+ res = self.base.urlopen(url, mode='w+')
|
|
|
3ab372 |
try:
|
|
|
3ab372 |
json_parse = json.loads(res.read())
|
|
|
3ab372 |
except ValueError:
|
|
|
3ab372 |
raise dnf.exceptions.Error(
|
|
|
3ab372 |
_("Can't parse repositories for username '{}'.")
|
|
|
3ab372 |
.format(user_name))
|
|
|
3ab372 |
self._check_json_output(json_parse)
|
|
|
3ab372 |
section_text = _("List of {} coprs").format(user_name)
|
|
|
3ab372 |
self._print_match_section(section_text)
|
|
|
3ab372 |
- i = 0
|
|
|
3ab372 |
- while i < len(json_parse["repos"]):
|
|
|
3ab372 |
- msg = "{0}/{1} : ".format(user_name,
|
|
|
3ab372 |
- json_parse["repos"][i]["name"])
|
|
|
3ab372 |
- desc = json_parse["repos"][i]["description"]
|
|
|
3ab372 |
- if not desc:
|
|
|
3ab372 |
- desc = _("No description given")
|
|
|
3ab372 |
+
|
|
|
3ab372 |
+ for item in json_parse["items"]:
|
|
|
3ab372 |
+ msg = "{0}/{1} : ".format(user_name, item["name"])
|
|
|
3ab372 |
+ desc = item["description"] or _("No description given")
|
|
|
3ab372 |
msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
|
|
|
3ab372 |
print(msg)
|
|
|
3ab372 |
- i += 1
|
|
|
3ab372 |
|
|
|
3ab372 |
def _search(self, query):
|
|
|
3ab372 |
- # http://copr.fedorainfracloud.org/api/coprs/search/tests/
|
|
|
3ab372 |
- api_path = "/api/coprs/search/{}/".format(query)
|
|
|
3ab372 |
- res = self.base.urlopen(self.copr_url + api_path, mode='w+')
|
|
|
3ab372 |
+ # https://copr.fedorainfracloud.org/api_3/project/search?query=tests
|
|
|
3ab372 |
+ api_path = "/api_3/project/search?query={}".format(query)
|
|
|
3ab372 |
+ url = self.copr_url + api_path
|
|
|
3ab372 |
+ res = self.base.urlopen(url, mode='w+')
|
|
|
3ab372 |
try:
|
|
|
3ab372 |
json_parse = json.loads(res.read())
|
|
|
3ab372 |
except ValueError:
|
|
|
3ab372 |
raise dnf.exceptions.Error(_("Can't parse search for '{}'."
|
|
|
3ab372 |
).format(query))
|
|
|
3ab372 |
self._check_json_output(json_parse)
|
|
|
3ab372 |
section_text = _("Matched: {}").format(query)
|
|
|
3ab372 |
self._print_match_section(section_text)
|
|
|
3ab372 |
- i = 0
|
|
|
3ab372 |
- while i < len(json_parse["repos"]):
|
|
|
3ab372 |
- msg = "{0}/{1} : ".format(json_parse["repos"][i]["username"],
|
|
|
3ab372 |
- json_parse["repos"][i]["coprname"])
|
|
|
3ab372 |
- desc = json_parse["repos"][i]["description"]
|
|
|
3ab372 |
- if not desc:
|
|
|
3ab372 |
- desc = _("No description given.")
|
|
|
3ab372 |
+
|
|
|
3ab372 |
+ for item in json_parse["items"]:
|
|
|
3ab372 |
+ msg = "{0} : ".format(item["full_name"])
|
|
|
3ab372 |
+ desc = item["description"] or _("No description given.")
|
|
|
3ab372 |
msg = self.base.output.fmtKeyValFill(ucd(msg), desc)
|
|
|
3ab372 |
print(msg)
|
|
|
3ab372 |
- i += 1
|
|
|
3ab372 |
|
|
|
3ab372 |
def _print_match_section(self, text):
|
|
|
3ab372 |
formatted = self.base.output.fmtSection(text)
|
|
|
3ab372 |
@@ -624,7 +618,7 @@ Bugzilla. In case of problems, contact the owner of this repository.
|
|
|
3ab372 |
|
|
|
3ab372 |
@classmethod
|
|
|
3ab372 |
def _check_json_output(cls, json_obj):
|
|
|
3ab372 |
- if json_obj["output"] != "ok":
|
|
|
3ab372 |
+ if "error" in json_obj:
|
|
|
3ab372 |
raise dnf.exceptions.Error("{}".format(json_obj["error"]))
|
|
|
3ab372 |
|
|
|
3ab372 |
@classmethod
|
|
|
3ab372 |
--
|
|
|
3ab372 |
libgit2 1.0.1
|
|
|
3ab372 |
|