public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dbapi/, pym/portage/
@ 2011-03-27 21:00 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2011-03-27 21:00 UTC (permalink / raw
  To: gentoo-commits

commit:     c66a8136b431ec42ea02e6378ed1f6981d7ef81a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 27 20:55:11 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Mar 27 20:58:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c66a8136

UnsupportedAPIException: handle unicode in EAPI

Normally EAPI doesn't contain unicode, but as in bug #359675, it can
contain practically anything if files in /var/db/pkg are corrupt.

---
 pym/portage/dbapi/vartree.py |    2 +-
 pym/portage/exception.py     |   17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index ce94fa4..a9e8ede 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1536,7 +1536,7 @@ class dblink(object):
 				showMessage(_("!!! FAILED prerm: %s\n") % \
 					os.path.join(self.dbdir, "EAPI"),
 					level=logging.ERROR, noiselevel=-1)
-				showMessage("%s\n" % (e,),
+				showMessage(_unicode_decode("%s\n") % (e,),
 					level=logging.ERROR, noiselevel=-1)
 				myebuildpath = None
 

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 64d0f7b..7891120 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2004 Gentoo Foundation
+# Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import signal
@@ -150,13 +150,24 @@ class UnsupportedAPIException(PortagePackageException):
 	def __init__(self, cpv, eapi):
 		self.cpv, self.eapi = cpv, eapi
 	def __str__(self):
+		eapi = self.eapi
+		if not isinstance(eapi, basestring):
+			eapi = str(eapi)
+		eapi = eapi.lstrip("-")
 		msg = _("Unable to do any operations on '%(cpv)s', since "
 		"its EAPI is higher than this portage version's. Please upgrade"
 		" to a portage version that supports EAPI '%(eapi)s'.") % \
-		{"cpv": self.cpv, "eapi": str(self.eapi).lstrip("-")}
-		return msg
+		{"cpv": self.cpv, "eapi": eapi}
+		return _unicode_decode(msg,
+			encoding=_encodings['content'], errors='replace')
 
+	if sys.hexversion < 0x3000000:
+
+		__unicode__ = __str__
 
+		def __str__(self):
+			return _unicode_encode(self.__unicode__(),
+				encoding=_encodings['content'], errors='backslashreplace')
 
 class SignatureException(PortageException):
 	"""Signature was not present in the checked file"""



^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dbapi/, pym/portage/
@ 2011-02-14  4:31 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2011-02-14  4:31 UTC (permalink / raw
  To: gentoo-commits

commit:     04cd72a0dd768f741f64bc1cf1bbf4367cd877d1
Author:     David James <davidjames <AT> google <DOT> com>
AuthorDate: Fri Feb 11 17:25:26 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 14 04:30:46 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=04cd72a0

Add support for grabbing Packages files using external programs.

If the user specifies FETCHCOMMAND_*, Portage should honor this when grabbing
Packages files. This allows users to setup support for grabbing Packages files
from other protocols.

BUG=chrome-os-partner:2026
TEST=Try downloading prebuilts from gs:// when FETCHCOMMAND_GS is setup in make.conf

Change-Id: I96b239819351633dd02d608954e81a1c363a4687

Review URL: http://codereview.chromium.org/6458015

---
 pym/portage/dbapi/bintree.py |   16 ++++++++++++++--
 pym/portage/getbinpkg.py     |    6 ++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index c424d16..0271bfa 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -770,8 +770,9 @@ class binarytree(object):
 				# urlparse.urljoin() only works correctly with recognized
 				# protocols and requires the base url to have a trailing
 				# slash, so join manually...
+				url = base_url.rstrip("/") + "/Packages"
 				try:
-					f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
+					f = urllib_request_urlopen(url)
 				except IOError:
 					path = parsed_url.path.rstrip("/") + "/Packages"
 
@@ -796,7 +797,18 @@ class binarytree(object):
 							stdout=subprocess.PIPE)
 						f = proc.stdout
 					else:
-						raise
+						setting = 'FETCHCOMMAND_' + parsed_url.scheme.upper()
+						fcmd = self.settings.get(setting)
+						if not fcmd:
+							raise
+						fd, tmp_filename = tempfile.mkstemp()
+						tmp_dirname, tmp_basename = os.path.split(tmp_filename)
+						os.close(fd)
+						success = portage.getbinpkg.file_get(url,
+						     tmp_dirname, fcmd=fcmd, filename=tmp_basename)
+						if not success:
+							raise portage.exception.FileNotFound(url)
+						f = open(tmp_filename, 'rb')
 
 				f_dec = codecs.iterdecode(f,
 					_encodings['repo.content'], errors='replace')

diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index f85b65c..43a6bf5 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -431,17 +431,19 @@ def file_get_metadata(baseurl,conn=None, chunk_size=3000):
 	return myid
 
 
-def file_get(baseurl,dest,conn=None,fcmd=None):
+def file_get(baseurl,dest,conn=None,fcmd=None,filename=None):
 	"""(baseurl,dest,fcmd=) -- Takes a base url to connect to and read from.
 	URI should be in the form <proto>://[user[:pass]@]<site>[:port]<path>"""
 
 	if not fcmd:
 		return file_get_lib(baseurl,dest,conn)
+	if not filename:
+		filename = os.path.basename(baseurl)
 
 	variables = {
 		"DISTDIR": dest,
 		"URI":     baseurl,
-		"FILE":    os.path.basename(baseurl)
+		"FILE":    filename
 	}
 
 	from portage.util import varexpand



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

end of thread, other threads:[~2011-03-27 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-27 21:00 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dbapi/, pym/portage/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2011-02-14  4:31 Zac Medico

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