aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-11-04 19:24:15 -0700
committerZac Medico <zmedico@gentoo.org>2010-11-04 19:24:15 -0700
commit36bb9d8ecf9f66b2d5d6c9733b022671aac0daad (patch)
treef5585b7a6022f8727cc0a3d7f089113b1c3d98d2 /pym/portage/dbapi/bintree.py
parentbinarytree: handle binhost port for sftp/ssh (diff)
downloadportage-36bb9d8ecf9f66b2d5d6c9733b022671aac0daad.tar.gz
portage-36bb9d8ecf9f66b2d5d6c9733b022671aac0daad.tar.bz2
portage-36bb9d8ecf9f66b2d5d6c9733b022671aac0daad.zip
complete binhost ssh/sftp port support
Diffstat (limited to 'pym/portage/dbapi/bintree.py')
-rw-r--r--pym/portage/dbapi/bintree.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index ee3721806..a4ec224e3 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -740,9 +740,16 @@ class binarytree(object):
if getbinpkgs and 'PORTAGE_BINHOST' in self.settings:
base_url = self.settings["PORTAGE_BINHOST"]
- urldata = urlparse(base_url)
+ parsed_url = urlparse(base_url)
+ host = parsed_url.netloc
+ port = parsed_url.port
+ port_args = []
+ if port is not None:
+ port_str = ":%s" % (port,)
+ if host.endswith(port_str):
+ host = host[:-len(port_str)]
pkgindex_file = os.path.join(self.settings["EROOT"], CACHE_PATH, "binhost",
- urldata[1] + urldata[2], "Packages")
+ host, parsed_url.path.lstrip("/"), "Packages")
pkgindex = self._new_pkgindex()
try:
f = codecs.open(_unicode_encode(pkgindex_file,
@@ -758,7 +765,6 @@ class binarytree(object):
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
rmt_idx = self._new_pkgindex()
- parsed_url = urlparse(base_url)
proc = None
tmp_filename = None
try:
@@ -769,13 +775,6 @@ class binarytree(object):
f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
except IOError:
path = parsed_url.path.rstrip("/") + "/Packages"
- host = parsed_url.netloc
- port = parsed_url.port
- port_args = []
- if port is not None:
- port_str = ":%s" % (port,)
- if host.endswith(port_str):
- host = host[:-len(port_str)]
if parsed_url.scheme == 'sftp':
# The sftp command complains about 'Illegal seek' if
@@ -784,7 +783,7 @@ class binarytree(object):
fd, tmp_filename = tempfile.mkstemp()
os.close(fd)
if port is not None:
- port_args = ['-P', port]
+ port_args = ['-P', "%s" % (port,)]
proc = subprocess.Popen(['sftp'] + port_args + \
[host + ":" + path, tmp_filename])
if proc.wait() != os.EX_OK:
@@ -792,7 +791,7 @@ class binarytree(object):
f = open(tmp_filename, 'rb')
elif parsed_url.scheme == 'ssh':
if port is not None:
- port_args = ['-p', port]
+ port_args = ['-p', "%s" % (port,)]
proc = subprocess.Popen(['ssh'] + port_args + \
[host, '--', 'cat', path], stdout=subprocess.PIPE)
f = proc.stdout