本文整理汇总了Python中paramiko.Transport.open_sftp_client方法的典型用法代码示例。如果您正苦于以下问题:Python Transport.open_sftp_client方法的具体用法?Python Transport.open_sftp_client怎么用?Python Transport.open_sftp_client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paramiko.Transport
的用法示例。
在下文中一共展示了Transport.open_sftp_client方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createConnection
# 需要导入模块: from paramiko import Transport [as 别名]
# 或者: from paramiko.Transport import open_sftp_client [as 别名]
def _createConnection(self):
"""
@see: L{_createConnection<datafinder.persistence.common.connection.pool.ConnectionPool._createConnection>}
"""
try:
connection = Transport((self._configuration.hostname, constants.DEFAULT_SSH_PORT))
connection.connect(username=self._configuration.username, password=self._configuration.password)
return connection.open_sftp_client()
except (SSHException, socket.error, socket.gaierror), error:
errorMessage = u"Unable to establish SFTP connection to host '%s'! " \
% (self._configuration.hostname) + "\nReason: '%s'" % str(error)
raise PersistenceError(errorMessage)
示例2: main
# 需要导入模块: from paramiko import Transport [as 别名]
# 或者: from paramiko.Transport import open_sftp_client [as 别名]
def main():
try:
from paramiko import Transport
except ImportError:
print
print "To upload you need to install paramiko python library from:"
print "http://www.lag.net/paramiko",
print "or on ubuntu go: apt-get install python2.4-paramiko"
print
sys.exit(2)
# Setup for eduforge
server = "shell.eduforge.org"
basedir = "/home/pub/exe/"
print "Please enter password for %[email protected]%s:" % (sys.argv[-1], server)
password = getpass()
# Get the version
# Rename the files
print "Renaming files"
install = Path("eXe_install_windows.exe")
newName = Path("eXe-install-%s.exe" % release)
install = renameFile(install, newName)
ready2run = Path("exes.exe")
newName = Path("eXe-ready2run-%s.exe" % release)
ready2run = renameFile(ready2run, newName)
# Upload
print "Uploading"
print "connecting to %s..." % server
from socket import socket, gethostbyname
s = socket()
s.connect((gethostbyname(server), 22))
t = Transport(s)
t.connect()
t.auth_password(sys.argv[-1], password)
sftp = t.open_sftp_client()
sftp.chdir(basedir)
upFile(sftp, install)
upFile(sftp, ready2run)