[projects/pld-ftp-admin] Accomodate for urlopen() moving from urllib to urllib.request in python3

baggins baggins at pld-linux.org
Sun Jan 17 11:46:32 CET 2021


commit 3943100fefdf8d649e1b2707830b7ad19ea5721e
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Jan 17 11:37:35 2021 +0100

    Accomodate for urlopen() moving from urllib to urllib.request in python3

 modules/ftptree.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/modules/ftptree.py b/modules/ftptree.py
index 3b1af3c..0200a10 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -2,7 +2,16 @@
 
 from __future__ import print_function
 
-import os, config, string, urllib, re, rpm
+import os
+import config
+import string
+try:
+    import urllib.request as urlmess
+except ImportError:
+    import urllib as urlmess
+    pass
+import re
+import rpm
 from common import fileexists, noarchcachedir
 from baseftptree import BasePkg, BaseFtpTree
 from sign import is_signed
@@ -400,11 +409,11 @@ class FtpTree(BaseFtpTree):
 
         Reads config.builderqueue to grab the info
         """
-        f = urllib.urlopen(config.builderqueue)
+        f = urlmess.urlopen(config.builderqueue)
         requests = {}
         reid = re.compile(r'^.*id=(.*) pri.*$')
         regb = re.compile(r'^group:.*$|builders:.*$', re.M)
-        for i in re.findall(regb, f.read()):
+        for i in re.findall(regb, f.read().decode('utf-8')):
             if i[0] == 'g':
                 id = reid.sub(r'\1', i)
                 requests[id] = ""
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/7aec4c36547d10c790a119a1ac203eee13755a6d



More information about the pld-cvs-commit mailing list