Blame SOURCES/0020-Shorter-verification-that-the-project-exists.patch

2d80f0
From bf230d570763acc6ccd4f4b3951f4b8325a8e4b8 Mon Sep 17 00:00:00 2001
2d80f0
From: Silvie Chlupova <sisi.chlupova@gmail.com>
2d80f0
Date: Fri, 3 Sep 2021 15:45:43 +0200
2d80f0
Subject: [PATCH] Shorter verification that the project exists
2d80f0
2d80f0
---
2d80f0
 plugins/copr.py | 16 ++++++----------
2d80f0
 1 file changed, 6 insertions(+), 10 deletions(-)
2d80f0
2d80f0
diff --git a/plugins/copr.py b/plugins/copr.py
2d80f0
index 9f597dd..1539c0d 100644
2d80f0
--- a/plugins/copr.py
2d80f0
+++ b/plugins/copr.py
2d80f0
@@ -70,8 +70,10 @@ NO = set([_('no'), _('n'), ''])
2d80f0
 
2d80f0
 if PY3:
2d80f0
     from configparser import ConfigParser, NoOptionError, NoSectionError
2d80f0
+    from urllib.request import urlopen, HTTPError
2d80f0
 else:
2d80f0
     from ConfigParser import ConfigParser, NoOptionError, NoSectionError
2d80f0
+    from urllib2 import urlopen, HTTPError
2d80f0
 
2d80f0
 @dnf.plugin.register_command
2d80f0
 class CoprCommand(dnf.cli.Command):
2d80f0
@@ -478,17 +480,11 @@ Bugzilla. In case of problems, contact the owner of this repository.
2d80f0
             if os.path.exists(repo_filename):
2d80f0
                 os.remove(repo_filename)
2d80f0
             if '404' in str(e):
2d80f0
-                if PY3:
2d80f0
-                    import urllib.request
2d80f0
-                    try:
2d80f0
-                        res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name)
2d80f0
-                        status_code = res.getcode()
2d80f0
-                    except urllib.error.HTTPError as e:
2d80f0
-                        status_code = e.getcode()
2d80f0
-                else:
2d80f0
-                    import urllib
2d80f0
-                    res = urllib.urlopen(self.copr_url + "/coprs/" + project_name)
2d80f0
+                try:
2d80f0
+                    res = urlopen(self.copr_url + "/coprs/" + project_name)
2d80f0
                     status_code = res.getcode()
2d80f0
+                except HTTPError as e:
2d80f0
+                    status_code = e.getcode()
2d80f0
                 if str(status_code) != '404':
2d80f0
                     raise dnf.exceptions.Error(_("This repository does not have"
2d80f0
                                                  " any builds yet so you cannot enable it now."))
2d80f0
-- 
2d80f0
2.36.1
2d80f0