From f28d69dc833fd05a151d5763aaf005e7d1c68470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kadl=C4=8D=C3=ADk?= Date: Wed, 19 Oct 2016 01:13:33 +0200 Subject: [PATCH] Use Copr API to get DNF repo URL --- module_build_service/pdc.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/module_build_service/pdc.py b/module_build_service/pdc.py index 309a13bb..7e8cee16 100644 --- a/module_build_service/pdc.py +++ b/module_build_service/pdc.py @@ -28,7 +28,8 @@ import modulemd from pdc_client import PDCClient import six -import os +import requests +import json @@ -172,17 +173,16 @@ def get_module_repo(session, module_info, strict=False): raise NotImplementedError # Module was built in Copr - # @TODO get the correct user - owner, project = "@copr", module["variant_id"] - - # Some user/group logic. We should really be using python-copr for that - g = "" - if owner[0] == "@": - g = "/g" - owner = owner[1:] - base = "http://copr-fe-dev.cloud.fedoraproject.org" - return "{}/coprs{}/{}/{}/repo/modules".format(base, g, owner, project) + + # @TODO get the correct user + data = {"owner": "@copr", "nvr": module["variant_id"]} + r = requests.post("{}/api/module/repo/".format(base), data=data) + response = json.loads(r.content) + + if response["output"] == "notok": + raise ValueError(response["error"]) + return response["repo"] def module_depsolving_wrapper(session, module_list, strict=True): """