diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-06-25 03:23:17 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-06-25 03:23:17 +0000 |
commit | 927640cd20304b1a58601f9e1b58fa011d8bcb20 (patch) | |
tree | 97526d82681057e7dfadf9f3dc8df352bc461df4 | |
parent | 923ccec33c4b677fdbb3909786c6956ac2a6cb0b (diff) | |
download | portage-927640cd20304b1a58601f9e1b58fa011d8bcb20.tar.gz portage-927640cd20304b1a58601f9e1b58fa011d8bcb20.tar.bz2 portage-927640cd20304b1a58601f9e1b58fa011d8bcb20.zip |
For bug #175891, add sftp protocol support via the paramiko library.
svn path=/main/trunk/; revision=7023
-rw-r--r-- | pym/portage/getbinpkg.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index f1131c2d6..a1fec9d20 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -141,6 +141,15 @@ def create_conn(baseurl,conn=None): conn.login(username) conn.set_pasv(passive) conn.set_debuglevel(0) + elif protocol == "sftp": + try: + import paramiko + except ImportError: + raise NotImplementedError( + "paramiko must be installed for sftp support") + t = paramiko.Transport(host) + t.connect(username=username, password=password) + conn = paramiko.SFTPClient.from_transport(t) else: raise NotImplementedError, "%s is not a supported protocol." % protocol @@ -307,6 +316,8 @@ def dir_get_list(baseurl,conn=None): del olddir else: listing = conn.nlst(address) + elif protocol == "sftp": + listing = conn.listdir(address) else: raise TypeError, "Unknown protocol. '%s'" % protocol @@ -332,6 +343,13 @@ def file_get_metadata(baseurl,conn=None, chunk_size=3000): data,rc,msg = make_http_request(conn, address, params, headers) elif protocol in ["ftp"]: data,rc,msg = make_ftp_request(conn, address, -chunk_size) + elif protocol == "sftp": + f = conn.open(address) + try: + f.seek(-chunk_size, 2) + data = f.read() + finally: + f.close() else: raise TypeError, "Unknown protocol. '%s'" % protocol @@ -400,6 +418,8 @@ def file_get_lib(baseurl,dest,conn=None): data,rc,msg = make_http_request(conn, address, params, headers, dest=dest) elif protocol in ["ftp"]: data,rc,msg = make_ftp_request(conn, address, dest=dest) + elif protocol == "sftp": + conn.get(address, dest) else: raise TypeError, "Unknown protocol. '%s'" % protocol |