From c1075d63476ff5f848df9e761689bf0c639b5891 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 25 Jun 2007 04:47:35 +0000 Subject: Fix file_get_lib() so it behaves the same way with sftp as it does with other protocols. svn path=/main/trunk/; revision=7024 --- pym/portage/getbinpkg.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'pym/portage/getbinpkg.py') 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 -- cgit v1.2.3-1-g7c22