public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, bin/, pym/portage/, pym/portage/util/
@ 2012-05-01 19:54 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 2+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-05-01 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     0a9cc38a66ded0cf0e5b534cb24b970fc9c21920
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Tue May  1 19:51:16 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Tue May  1 19:51:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0a9cc38a

Bug #413983: Add portage.util.urlopen(), which transparently
handles authentication in the way compatible with Python 3.

---
 bin/repoman                  |    9 ++-------
 pym/portage/dbapi/bintree.py |    7 +++----
 pym/portage/glsa.py          |   10 +++-------
 pym/portage/util/__init__.py |   21 ++++++++++++++++++++-
 4 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/bin/repoman b/bin/repoman
index 1cdfcf6..cfe4b8e 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -25,11 +25,6 @@ import textwrap
 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
 
@@ -75,7 +70,7 @@ from portage.process import find_binary, spawn
 from portage.output import bold, create_color_func, \
 	green, nocolor, red
 from portage.output import ConsoleStyleFile, StyleWriter
-from portage.util import cmp_sort_key, writemsg_level
+from portage.util import cmp_sort_key, urlopen, 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
@@ -1051,7 +1046,7 @@ def fetch_metadata_dtd():
 			"needs to be refetched, doing that now")
 		print()
 		try:
-			url_f = urllib_request_urlopen(metadata_dtd_uri)
+			url_f = urlopen(metadata_dtd_uri)
 			msg_info = url_f.info()
 			last_modified = msg_info.get('last-modified')
 			if last_modified is not None:

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 2295b9f..810163d 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["bindbapi", "binarytree"]
@@ -26,6 +26,7 @@ from portage.dep import Atom, use_reduce, paren_enclose
 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
@@ -45,10 +46,8 @@ import warnings
 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
@@ -843,7 +842,7 @@ class binarytree(object):
 				# slash, so join manually...
 				url = base_url.rstrip("/") + "/Packages"
 				try:
-					f = urllib_request_urlopen(url)
+					f = urlopen(url)
 				except IOError:
 					path = parsed_url.path.rstrip("/") + "/Packages"
 

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 2df7ec3..16f662f 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -1,14 +1,10 @@
-# Copyright 2003-2011 Gentoo Foundation
+# Copyright 2003-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import absolute_import
 
 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
 
@@ -18,7 +14,7 @@ from portage import _encodings
 from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.versions import pkgsplit, catpkgsplit, pkgcmp, best
-from portage.util import grabfile
+from portage.util import grabfile, urlopen
 from portage.const import CACHE_PATH
 from portage.localization import _
 from portage.dep import _slot_separator
@@ -476,7 +472,7 @@ class Glsa:
 			myurl = "file://"+self.nr
 		else:
 			myurl = repository + "glsa-%s.xml" % str(self.nr)
-		self.parse(urllib_request_urlopen(myurl))
+		self.parse(urlopen(myurl))
 		return None
 
 	def parse(self, myfile):

diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index d6ac46c..2b50733 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2004-2011 Gentoo Foundation
+# Copyright 2004-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ['apply_permissions', 'apply_recursive_permissions',
@@ -26,6 +26,14 @@ import string
 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(),
@@ -1640,3 +1648,14 @@ def getlibpaths(root, env=None):
 	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)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, bin/, pym/portage/, pym/portage/util/
@ 2012-05-14  1:54 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-05-14  1:54 UTC (permalink / raw
  To: gentoo-commits

commit:     58a8cd1bb943522bc53d02c008ee8eff798bfaaa
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 14 01:53:50 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 14 01:53:50 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=58a8cd1b

Revert "Bug #413983: Add portage.util.urlopen(), which transparently handles authentication in the way compatible with Python 3."

This reverts commit 0a9cc38a66ded0cf0e5b534cb24b970fc9c21920. As
reported in bug #415579, that commit broke FTP authentication.

---
 bin/repoman                  |    9 +++++++--
 pym/portage/dbapi/bintree.py |    5 +++--
 pym/portage/glsa.py          |    8 ++++++--
 pym/portage/util/__init__.py |   19 -------------------
 4 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/bin/repoman b/bin/repoman
index 1fc9acc..3697403 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -25,6 +25,11 @@ import textwrap
 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
 
@@ -70,7 +75,7 @@ from portage.process import find_binary, spawn
 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
@@ -1046,7 +1051,7 @@ def fetch_metadata_dtd():
 			"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:

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 52b85b8..4ac48c9 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -26,7 +26,6 @@ from portage.dep import Atom, use_reduce, paren_enclose
 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
@@ -46,8 +45,10 @@ import warnings
 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
@@ -844,7 +845,7 @@ class binarytree(object):
 				# 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"
 

diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 0e59068..1857695 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -5,6 +5,10 @@ from __future__ import absolute_import
 
 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
 
@@ -14,7 +18,7 @@ from portage import _encodings
 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
@@ -469,7 +473,7 @@ class Glsa:
 			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):

diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 2b50733..57e8c37 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -26,14 +26,6 @@ import string
 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(),
@@ -1648,14 +1640,3 @@ def getlibpaths(root, env=None):
 	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)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-14  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-14  1:54 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, bin/, pym/portage/, pym/portage/util/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2012-05-01 19:54 Arfrever Frehtes Taifersar Arahesis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox