diff options
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 14fe3c753a..be01bdbb34 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -28,27 +28,23 @@ BitBake build tools. | |||
28 | import os, re | 28 | import os, re |
29 | import signal | 29 | import signal |
30 | import logging | 30 | import logging |
31 | import urllib | 31 | import urllib.request, urllib.parse, urllib.error |
32 | import urlparse | 32 | if 'git' not in urllib.parse.uses_netloc: |
33 | urllib.parse.uses_netloc.append('git') | ||
34 | import operator | ||
33 | import collections | 35 | import collections |
36 | import subprocess | ||
37 | import pickle | ||
34 | import bb.persist_data, bb.utils | 38 | import bb.persist_data, bb.utils |
35 | import bb.checksum | 39 | import bb.checksum |
36 | from bb import data | 40 | from bb import data |
37 | import bb.process | 41 | import bb.process |
38 | import subprocess | ||
39 | 42 | ||
40 | __version__ = "2" | 43 | __version__ = "2" |
41 | _checksum_cache = bb.checksum.FileChecksumCache() | 44 | _checksum_cache = bb.checksum.FileChecksumCache() |
42 | 45 | ||
43 | logger = logging.getLogger("BitBake.Fetcher") | 46 | logger = logging.getLogger("BitBake.Fetcher") |
44 | 47 | ||
45 | try: | ||
46 | import cPickle as pickle | ||
47 | except ImportError: | ||
48 | import pickle | ||
49 | logger.info("Importing cPickle failed. " | ||
50 | "Falling back to a very slow implementation.") | ||
51 | |||
52 | class BBFetchException(Exception): | 48 | class BBFetchException(Exception): |
53 | """Class all fetch exceptions inherit from""" | 49 | """Class all fetch exceptions inherit from""" |
54 | def __init__(self, message): | 50 | def __init__(self, message): |
@@ -230,14 +226,14 @@ class URI(object): | |||
230 | # them are not quite RFC compliant. | 226 | # them are not quite RFC compliant. |
231 | uri, param_str = (uri.split(";", 1) + [None])[:2] | 227 | uri, param_str = (uri.split(";", 1) + [None])[:2] |
232 | 228 | ||
233 | urlp = urlparse.urlparse(uri) | 229 | urlp = urllib.parse.urlparse(uri) |
234 | self.scheme = urlp.scheme | 230 | self.scheme = urlp.scheme |
235 | 231 | ||
236 | reparse = 0 | 232 | reparse = 0 |
237 | 233 | ||
238 | # Coerce urlparse to make URI scheme use netloc | 234 | # Coerce urlparse to make URI scheme use netloc |
239 | if not self.scheme in urlparse.uses_netloc: | 235 | if not self.scheme in urllib.parse.uses_netloc: |
240 | urlparse.uses_params.append(self.scheme) | 236 | urllib.parse.uses_params.append(self.scheme) |
241 | reparse = 1 | 237 | reparse = 1 |
242 | 238 | ||
243 | # Make urlparse happy(/ier) by converting local resources | 239 | # Make urlparse happy(/ier) by converting local resources |
@@ -248,7 +244,7 @@ class URI(object): | |||
248 | reparse = 1 | 244 | reparse = 1 |
249 | 245 | ||
250 | if reparse: | 246 | if reparse: |
251 | urlp = urlparse.urlparse(uri) | 247 | urlp = urllib.parse.urlparse(uri) |
252 | 248 | ||
253 | # Identify if the URI is relative or not | 249 | # Identify if the URI is relative or not |
254 | if urlp.scheme in self._relative_schemes and \ | 250 | if urlp.scheme in self._relative_schemes and \ |
@@ -264,7 +260,7 @@ class URI(object): | |||
264 | if urlp.password: | 260 | if urlp.password: |
265 | self.userinfo += ':%s' % urlp.password | 261 | self.userinfo += ':%s' % urlp.password |
266 | 262 | ||
267 | self.path = urllib.unquote(urlp.path) | 263 | self.path = urllib.parse.unquote(urlp.path) |
268 | 264 | ||
269 | if param_str: | 265 | if param_str: |
270 | self.params = self._param_str_split(param_str, ";") | 266 | self.params = self._param_str_split(param_str, ";") |
@@ -312,11 +308,11 @@ class URI(object): | |||
312 | 308 | ||
313 | @property | 309 | @property |
314 | def path_quoted(self): | 310 | def path_quoted(self): |
315 | return urllib.quote(self.path) | 311 | return urllib.parse.quote(self.path) |
316 | 312 | ||
317 | @path_quoted.setter | 313 | @path_quoted.setter |
318 | def path_quoted(self, path): | 314 | def path_quoted(self, path): |
319 | self.path = urllib.unquote(path) | 315 | self.path = urllib.parse.unquote(path) |
320 | 316 | ||
321 | @property | 317 | @property |
322 | def path(self): | 318 | def path(self): |
@@ -398,7 +394,7 @@ def decodeurl(url): | |||
398 | s1, s2 = s.split('=') | 394 | s1, s2 = s.split('=') |
399 | p[s1] = s2 | 395 | p[s1] = s2 |
400 | 396 | ||
401 | return type, host, urllib.unquote(path), user, pswd, p | 397 | return type, host, urllib.parse.unquote(path), user, pswd, p |
402 | 398 | ||
403 | def encodeurl(decoded): | 399 | def encodeurl(decoded): |
404 | """Encodes a URL from tokens (scheme, network location, path, | 400 | """Encodes a URL from tokens (scheme, network location, path, |
@@ -422,7 +418,7 @@ def encodeurl(decoded): | |||
422 | # Standardise path to ensure comparisons work | 418 | # Standardise path to ensure comparisons work |
423 | while '//' in path: | 419 | while '//' in path: |
424 | path = path.replace("//", "/") | 420 | path = path.replace("//", "/") |
425 | url += "%s" % urllib.quote(path) | 421 | url += "%s" % urllib.parse.quote(path) |
426 | if p: | 422 | if p: |
427 | for parm in p: | 423 | for parm in p: |
428 | url += ";%s=%s" % (parm, p[parm]) | 424 | url += ";%s=%s" % (parm, p[parm]) |
@@ -1735,7 +1731,7 @@ class FetchConnectionCache(object): | |||
1735 | del self.cache[cn] | 1731 | del self.cache[cn] |
1736 | 1732 | ||
1737 | def close_connections(self): | 1733 | def close_connections(self): |
1738 | for cn in self.cache.keys(): | 1734 | for cn in list(self.cache.keys()): |
1739 | self.cache[cn].close() | 1735 | self.cache[cn].close() |
1740 | del self.cache[cn] | 1736 | del self.cache[cn] |
1741 | 1737 | ||