]> code.ossystems Code Review - openembedded-core.git/commitdiff
scripts: python3: fix urllib imports
authorEd Bartosh <ed.bartosh@linux.intel.com>
Thu, 2 Jun 2016 10:12:50 +0000 (13:12 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Jun 2016 10:46:15 +0000 (11:46 +0100)
Some functions and classes have been moved from urllib[2]
to urllib.request and urllib.error in python 3.

Used new imports to make the code working in python 3.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/contrib/verify-homepage.py
scripts/send-error-report

index 265ff65d3cf53d1debf66b6484163d7eaa3073a3..18bb15b277eb74386449ea6c25b840bb9f380732 100755 (executable)
@@ -7,7 +7,7 @@
 import sys
 import os
 import subprocess
-import urllib2
+import urllib.request
 
 
 # Allow importing scripts/lib modules
@@ -47,7 +47,7 @@ def verifyHomepage(bbhandler):
             homepage = data.getVar("HOMEPAGE", True)
             if homepage:
                 try:
-                    urllib2.urlopen(homepage, timeout=5)
+                    urllib.request.urlopen(homepage, timeout=5)
                 except Exception:
                     count = count + wgetHomepage(os.path.basename(realfn), homepage)
             checked.append(realfn)
index ed78bd6ebb335adc763e3cd9cef5b27292944d5d..a9f6e42d17e011aa2c4cd433772051037e095747 100755 (executable)
@@ -7,7 +7,7 @@
 # Author: Andreea Proca <andreea.b.proca@intel.com>
 # Author: Michael Wood <michael.g.wood@intel.com>
 
-import urllib2
+import urllib.request, urllib.error
 import sys
 import json
 import os
@@ -25,10 +25,10 @@ log = logging.getLogger("send-error-report")
 logging.basicConfig(format='%(levelname)s: %(message)s')
 
 def getPayloadLimit(url):
-    req = urllib2.Request(url, None)
+    req = urllib.request.Request(url, None)
     try:
-        response = urllib2.urlopen(req)
-    except urllib2.URLError as e:
+        response = urllib.request.urlopen(req)
+    except urllib.error.URLError as e:
         # Use this opportunity to bail out if we can't even contact the server
         log.error("Could not contact server: " + url)
         log.error(e.reason)
@@ -136,10 +136,10 @@ def send_data(data, args):
     else:
         url = "http://"+args.server+"/ClientPost/"
 
-    req = urllib2.Request(url, data=data, headers=headers)
+    req = urllib.request.Request(url, data=data, headers=headers)
     try:
-        response = urllib2.urlopen(req)
-    except urllib2.HTTPError, e:
+        response = urllib.request.urlopen(req)
+    except urllib.error.HTTPError as e:
         logging.error(e.reason)
         sys.exit(1)