summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py38
1 files changed, 17 insertions, 21 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 14fe3c753a..af7162b153 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -28,27 +28,23 @@ BitBake build tools.
28import os, re 28import os, re
29import signal 29import signal
30import logging 30import logging
31import urllib 31import urllib.request, urllib.parse, urllib.error
32import urlparse 32if 'git' not in urllib.parse.uses_netloc:
33 urllib.parse.uses_netloc.append('git')
34import operator
33import collections 35import collections
36import subprocess
37import pickle
34import bb.persist_data, bb.utils 38import bb.persist_data, bb.utils
35import bb.checksum 39import bb.checksum
36from bb import data 40from bb import data
37import bb.process 41import bb.process
38import subprocess
39 42
40__version__ = "2" 43__version__ = "2"
41_checksum_cache = bb.checksum.FileChecksumCache() 44_checksum_cache = bb.checksum.FileChecksumCache()
42 45
43logger = logging.getLogger("BitBake.Fetcher") 46logger = logging.getLogger("BitBake.Fetcher")
44 47
45try:
46 import cPickle as pickle
47except ImportError:
48 import pickle
49 logger.info("Importing cPickle failed. "
50 "Falling back to a very slow implementation.")
51
52class BBFetchException(Exception): 48class 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
403def encodeurl(decoded): 399def 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])
@@ -847,7 +843,7 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None):
847 843
848 raise FetchError(error_message) 844 raise FetchError(error_message)
849 845
850 return output 846 return output.decode("utf-8")
851 847
852def check_network_access(d, info = "", url = None): 848def check_network_access(d, info = "", url = None):
853 """ 849 """
@@ -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