]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
More urlgrabber fixes for Ubuntu/Debian/Mint.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Feb 2013 15:01:16 +0000 (16:01 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Feb 2013 15:01:16 +0000 (16:01 +0100)
python/pakfire/downloader.py

index d9808597d3ae288ab18650cc4c7ea971e3760747..41aa529ace7b09d8d73ad981991c6db8b82ea6ab 100644 (file)
@@ -103,10 +103,18 @@ class PakfireGrabber(URLGrabber):
        def urlopen(self, filename, *args, **kwargs):
                self.check_offline_mode()
 
-               # However, urlopen requires the filename to be an ordinary string object.
-               filename = str(filename)
+               # This is for older versions of urlgrabber which are packaged in Debian
+               # and Ubuntu and cannot handle filenames as a normal Python string but need
+               # a unicode string.
+               return URLGrabber.urlopen(self, filename.encode("utf-8"), *args, **kwargs)
+
+       def urlgrab(self, url, *args, **kwargs):
+               self.check_offline_mode()
 
-               return URLGrabber.urlopen(self, filename, *args, **kwargs)
+               # This is for older versions of urlgrabber which are packaged in Debian
+               # and Ubuntu and cannot handle filenames as a normal Python string but need
+               # a unicode string.
+               return URLGrabber.urlgrab(self, url.encode("utf-8"), *args, **kwargs)
 
 
 class PackageDownloader(PakfireGrabber):