update-webkitgtk-flatpak fails if running with python2
authorHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2018 03:14:42 +0000 (03:14 +0000)
committerHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2018 03:14:42 +0000 (03:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187240

Reviewed by Michael Catanzaro.

urllib.urlretrieve of Python2 sends invalid requests. Use
urllib2.urlopen instead.

* flatpak/flatpakutils.py: Import urllib2.urlopen for Python2,
urllib.request.urlopen for Python3.
(FlatpakRepo.repo_file): Copy the content of urlopen result to the
temporary file.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233494 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/flatpak/flatpakutils.py

index fdf4984..60379e0 100644 (file)
@@ -1,3 +1,18 @@
+2018-07-03  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        update-webkitgtk-flatpak fails if running with python2
+        https://bugs.webkit.org/show_bug.cgi?id=187240
+
+        Reviewed by Michael Catanzaro.
+
+        urllib.urlretrieve of Python2 sends invalid requests. Use
+        urllib2.urlopen instead.
+
+        * flatpak/flatpakutils.py: Import urllib2.urlopen for Python2,
+        urllib.request.urlopen for Python3.
+        (FlatpakRepo.repo_file): Copy the content of urlopen result to the
+        temporary file.
+
 2018-07-03  Chris Dumez  <cdumez@apple.com>
 
         Make CallbackMap::invalidate() safe to re-enter
index 7d5b5ba..48d2561 100644 (file)
@@ -38,9 +38,9 @@ except ImportError:
     from urlparse import urlparse
 
 try:
-    from urllib.request import urlretrieve  # pylint: disable=E0611
+    from urllib.request import urlopen  # pylint: disable=E0611
 except ImportError:
-    from urllib import urlretrieve
+    from urllib2 import urlopen
 
 FLATPAK_REQ = [
     ("flatpak", "0.10.0"),
@@ -374,8 +374,9 @@ class FlatpakRepo(FlatpakObject):
             return self._repo_file
 
         assert self.repo_file_name
-        self._repo_file = tempfile.NamedTemporaryFile(mode="w")
-        urlretrieve(self.repo_file_name, self._repo_file.name)
+        self._repo_file = tempfile.NamedTemporaryFile(mode="wb")
+        self._repo_file.write(urlopen(self.repo_file_name).read())
+        self._repo_file.flush()
 
         return self._repo_file