import time
import platform
+try:
+ from urllib.request import urlopen as urllib_request_urlopen
+except ImportError:
+ from urllib import urlopen as urllib_request_urlopen
+
from itertools import chain
from stat import S_ISDIR
from portage.output import bold, create_color_func, \
green, nocolor, red
from portage.output import ConsoleStyleFile, StyleWriter
-from portage.util import cmp_sort_key, urlopen, writemsg_level
+from portage.util import writemsg_level
from portage.util._desktop_entry import validate_desktop_entry
from portage.package.ebuild.digestgen import digestgen
from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
"needs to be refetched, doing that now")
print()
try:
- url_f = urlopen(metadata_dtd_uri)
+ url_f = urllib_request_urlopen(metadata_dtd_uri)
msg_info = url_f.info()
last_modified = msg_info.get('last-modified')
if last_modified is not None:
from portage.exception import AlarmSignal, InvalidPackageName, \
PermissionDenied, PortageException
from portage.localization import _
-from portage.util import urlopen
from portage import _movefile
from portage import os
from portage import _encodings
from itertools import chain
try:
from urllib.parse import urlparse
+ from urllib.request import urlopen as urllib_request_urlopen
except ImportError:
from urlparse import urlparse
+ from urllib import urlopen as urllib_request_urlopen
if sys.hexversion >= 0x3000000:
basestring = str
# slash, so join manually...
url = base_url.rstrip("/") + "/Packages"
try:
- f = urlopen(url)
+ f = urllib_request_urlopen(url)
except IOError:
path = parsed_url.path.rstrip("/") + "/Packages"
import io
import sys
+try:
+ from urllib.request import urlopen as urllib_request_urlopen
+except ImportError:
+ from urllib import urlopen as urllib_request_urlopen
import re
import xml.dom.minidom
from portage import _unicode_decode
from portage import _unicode_encode
from portage.versions import pkgsplit, vercmp, best
-from portage.util import grabfile, urlopen
+from portage.util import grabfile
from portage.const import CACHE_PATH
from portage.localization import _
from portage.dep import _slot_separator
myurl = "file://"+self.nr
else:
myurl = repository + "glsa-%s.xml" % str(self.nr)
- self.parse(urlopen(myurl))
+ self.parse(urllib_request_urlopen(myurl))
return None
def parse(self, myfile):
import sys
import traceback
import glob
-try:
- import urllib.parse as urllib_parse
- import urllib.request as urllib_request
- from urllib.parse import splituser as urllib_parse_splituser
-except ImportError:
- import urlparse as urllib_parse
- import urllib2 as urllib_request
- from urllib import splituser as urllib_parse_splituser
import portage
portage.proxy.lazyimport.lazyimport(globals(),
rval.append("/lib")
return [normalize_path(x) for x in rval if x]
-
-def urlopen(url):
- parse_result = urllib_parse.urlparse(url)
- netloc = urllib_parse_splituser(parse_result.netloc)[1]
- url = urllib_parse.urlunparse((parse_result.scheme, netloc, parse_result.path, parse_result.params, parse_result.query, parse_result.fragment))
- password_manager = urllib_request.HTTPPasswordMgrWithDefaultRealm()
- if parse_result.username is not None:
- password_manager.add_password(None, url, parse_result.username, parse_result.password)
- auth_handler = urllib_request.HTTPBasicAuthHandler(password_manager)
- opener = urllib_request.build_opener(auth_handler)
- return opener.open(url)