summaryrefslogtreecommitdiffstats
path: root/pym/portage/getbinpkg.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-25 04:47:35 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-25 04:47:35 +0000
commitc1075d63476ff5f848df9e761689bf0c639b5891 (patch)
tree63ca4fba266aaa67b891d3121c33a5d2f321b087 /pym/portage/getbinpkg.py
parent927640cd20304b1a58601f9e1b58fa011d8bcb20 (diff)
downloadportage-c1075d63476ff5f848df9e761689bf0c639b5891.tar.gz
portage-c1075d63476ff5f848df9e761689bf0c639b5891.tar.bz2
portage-c1075d63476ff5f848df9e761689bf0c639b5891.zip
Fix file_get_lib() so it behaves the same way with sftp as it does with other protocols.
svn path=/main/trunk/; revision=7024
Diffstat (limited to 'pym/portage/getbinpkg.py')
-rw-r--r--pym/portage/getbinpkg.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index a1fec9d20..b5a15aaaf 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -419,7 +419,22 @@ def file_get_lib(baseurl,dest,conn=None):
elif protocol in ["ftp"]:
data,rc,msg = make_ftp_request(conn, address, dest=dest)
elif protocol == "sftp":
- conn.get(address, dest)
+ rc = 0
+ try:
+ f = conn.open(address)
+ except Exception:
+ rc = 1
+ else:
+ try:
+ if dest:
+ bufsize = 8192
+ while True:
+ data = f.read(bufsize)
+ if not data:
+ break
+ dest.write(data)
+ finally:
+ f.close()
else:
raise TypeError, "Unknown protocol. '%s'" % protocol