diff options
author | Guido Günther <agx@sigxcpu.org> | 2015-05-28 20:25:31 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-06-10 09:07:33 +0200 |
commit | 21eaad96e9445a015e579f3f4b280b7f7fd95987 (patch) | |
tree | adc9cb528e69b4670eb4b27926f2b68f1ecb34f8 | |
parent | eff79b17b2cf6bd334853c2f3a9ab3a05009049d (diff) |
Make urllib invocations Python3 compatible
Git-Dch: Ignore
-rwxr-xr-x | gbp/scripts/import_srpm.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index 587e2f25..5f9b738b 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -25,7 +25,7 @@ import glob import time import shutil import errno -import urllib2 +from six.moves import urllib import gbp.tmpfile as tempfile import gbp.command_wrappers as gbpc @@ -53,20 +53,20 @@ def download_file(target_dir, url): """Download a remote file""" gbp.log.info("Downloading '%s'..." % url) try: - urlobj = urllib2.urlopen(url) + urlobj = urllib.urlopen(url) local_fn = os.path.join(target_dir, os.path.basename(url)) with open(local_fn, "wb") as local_file: local_file.write(urlobj.read()) - except urllib2.HTTPError as err: + except urllib.error.HTTPError as err: raise GbpError("Download failed: %s" % err) - except urllib2.URLError as err: + except urllib.error.URLError as err: raise GbpError("Download failed: %s" % err.reason) return local_fn def download_source(pkg, dirs): """Download package from a remote location""" if re.match(r'[a-z]{1,5}://', pkg): - mode = 'python urllib2' + mode = 'python urllib' else: mode = 'yumdownloader' |