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
del olddir
else:
listing = conn.nlst(address)
+ elif protocol == "sftp":
+ listing = conn.listdir(address)
else:
raise TypeError, "Unknown protocol. '%s'" % protocol
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
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