diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-06-02 13:12:50 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-03 13:13:29 +0100 |
commit | f6f10858e5464445016cd4eff20878804d4cb858 (patch) | |
tree | d515e89b815c72da32387531d1e53b8fadce33fb /scripts | |
parent | ee31bad7627a7c8590a5a7dd3ffc210872067f44 (diff) | |
download | poky-f6f10858e5464445016cd4eff20878804d4cb858.tar.gz |
scripts: python3: fix urllib imports
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.
(From OE-Core rev: ec3f1759e8b491a44a1fc1ecb6f89919dd30da97)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/contrib/verify-homepage.py | 4 | ||||
-rwxr-xr-x | scripts/send-error-report | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/scripts/contrib/verify-homepage.py b/scripts/contrib/verify-homepage.py index 265ff65d3c..18bb15b277 100755 --- a/scripts/contrib/verify-homepage.py +++ b/scripts/contrib/verify-homepage.py | |||
@@ -7,7 +7,7 @@ | |||
7 | import sys | 7 | import sys |
8 | import os | 8 | import os |
9 | import subprocess | 9 | import subprocess |
10 | import urllib2 | 10 | import urllib.request |
11 | 11 | ||
12 | 12 | ||
13 | # Allow importing scripts/lib modules | 13 | # Allow importing scripts/lib modules |
@@ -47,7 +47,7 @@ def verifyHomepage(bbhandler): | |||
47 | homepage = data.getVar("HOMEPAGE", True) | 47 | homepage = data.getVar("HOMEPAGE", True) |
48 | if homepage: | 48 | if homepage: |
49 | try: | 49 | try: |
50 | urllib2.urlopen(homepage, timeout=5) | 50 | urllib.request.urlopen(homepage, timeout=5) |
51 | except Exception: | 51 | except Exception: |
52 | count = count + wgetHomepage(os.path.basename(realfn), homepage) | 52 | count = count + wgetHomepage(os.path.basename(realfn), homepage) |
53 | checked.append(realfn) | 53 | checked.append(realfn) |
diff --git a/scripts/send-error-report b/scripts/send-error-report index ed78bd6ebb..a9f6e42d17 100755 --- a/scripts/send-error-report +++ b/scripts/send-error-report | |||
@@ -7,7 +7,7 @@ | |||
7 | # Author: Andreea Proca <andreea.b.proca@intel.com> | 7 | # Author: Andreea Proca <andreea.b.proca@intel.com> |
8 | # Author: Michael Wood <michael.g.wood@intel.com> | 8 | # Author: Michael Wood <michael.g.wood@intel.com> |
9 | 9 | ||
10 | import urllib2 | 10 | import urllib.request, urllib.error |
11 | import sys | 11 | import sys |
12 | import json | 12 | import json |
13 | import os | 13 | import os |
@@ -25,10 +25,10 @@ log = logging.getLogger("send-error-report") | |||
25 | logging.basicConfig(format='%(levelname)s: %(message)s') | 25 | logging.basicConfig(format='%(levelname)s: %(message)s') |
26 | 26 | ||
27 | def getPayloadLimit(url): | 27 | def getPayloadLimit(url): |
28 | req = urllib2.Request(url, None) | 28 | req = urllib.request.Request(url, None) |
29 | try: | 29 | try: |
30 | response = urllib2.urlopen(req) | 30 | response = urllib.request.urlopen(req) |
31 | except urllib2.URLError as e: | 31 | except urllib.error.URLError as e: |
32 | # Use this opportunity to bail out if we can't even contact the server | 32 | # Use this opportunity to bail out if we can't even contact the server |
33 | log.error("Could not contact server: " + url) | 33 | log.error("Could not contact server: " + url) |
34 | log.error(e.reason) | 34 | log.error(e.reason) |
@@ -136,10 +136,10 @@ def send_data(data, args): | |||
136 | else: | 136 | else: |
137 | url = "http://"+args.server+"/ClientPost/" | 137 | url = "http://"+args.server+"/ClientPost/" |
138 | 138 | ||
139 | req = urllib2.Request(url, data=data, headers=headers) | 139 | req = urllib.request.Request(url, data=data, headers=headers) |
140 | try: | 140 | try: |
141 | response = urllib2.urlopen(req) | 141 | response = urllib.request.urlopen(req) |
142 | except urllib2.HTTPError, e: | 142 | except urllib.error.HTTPError as e: |
143 | logging.error(e.reason) | 143 | logging.error(e.reason) |
144 | sys.exit(1) | 144 | sys.exit(1) |
145 | 145 | ||