From 4fbcaef8d7ff602606bcf26d1c3ce1a30da6c9a4 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 25 Jun 2007 04:50:48 +0000 Subject: [PATCH] Fix file_get_lib() so it behaves the same way with sftp as it does with other protocols. (trunk r7023:7024) svn path=/main/branches/2.1.2/; revision=7026 --- pym/getbinpkg.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py index 8bd43f29c..9484d1d16 100644 --- a/pym/getbinpkg.py +++ b/pym/getbinpkg.py @@ -419,7 +419,24 @@ 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 SystemExit: + raise + 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 -- 2.26.2