本文整理匯總了Python中paramiko.transport.Transport方法的典型用法代碼示例。如果您正苦於以下問題:Python transport.Transport方法的具體用法?Python transport.Transport怎麽用?Python transport.Transport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類paramiko.transport
的用法示例。
在下文中一共展示了transport.Transport方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: close
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def close(self):
"""
Close this SSHClient and its underlying `.Transport`.
.. warning::
Failure to do this may, in some situations, cause your Python
interpreter to hang at shutdown (often due to race conditions).
It's good practice to `close` your client objects anytime you're
done using them, instead of relying on garbage collection.
"""
if self._transport is None:
return
self._transport.close()
self._transport = None
if self._agent is not None:
self._agent.close()
self._agent = None
示例2: close
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def close(self):
"""
Close this SSHClient and its underlying L{Transport}.
"""
if self._transport is None:
return
self._transport.close()
self._transport = None
if self._agent != None:
self._agent.close()
self._agent = None
示例3: get_transport
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def get_transport(self):
"""
Return the underlying L{Transport} object for this SSH connection.
This can be used to perform lower-level tasks, like opening specific
kinds of channels.
@return: the Transport for this connection
@rtype: L{Transport}
"""
return self._transport
示例4: close
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def close(self):
"""
Close this SSHClient and its underlying `.Transport`.
"""
if self._transport is None:
return
self._transport.close()
self._transport = None
if self._agent is not None:
self._agent.close()
self._agent = None
示例5: get_transport
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def get_transport(self):
"""
Return the underlying `.Transport` object for this SSH connection.
This can be used to perform lower-level tasks, like opening specific
kinds of channels.
:return: the `.Transport` for this connection
"""
return self._transport
示例6: connect
# 需要導入模塊: from paramiko import transport [as 別名]
# 或者: from paramiko.transport import Transport [as 別名]
def connect(self, timeout=None):
if self._plugin_ssh_config is None:
raise Exception("no config!")
if self._plugin_ssh_config["nested_config"] is None:
try:
self._client.connect(hostname=self._plugin_ssh_config["hostname"], port=self._plugin_ssh_config["port"],
username=self._plugin_ssh_config["username"], password=self._plugin_ssh_config["password"], key_filename=self._plugin_ssh_config["identityfile"], timeout=timeout)
except Exception as e:
print(e)
raise Exception("connect failed!")
return
def __create_and_connect_transport(transport_sock, username, password, identityfile):
t = self._client._transport = Transport(transport_sock)
self._chained_transports.append(t)
t.start_client()
# ResourceManager.register(self._client, t)
if self._client._log_channel is not None:
t.set_log_channel(self._client._log_channel)
self._client._auth(username, password, None, identityfile, True, True, None, None, None, None)
config_chain = self._plugin_ssh_config.export_config_chain()
plugin_ssh_config = config_chain.pop()
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if timeout is not None:
sock.settimeout(timeout)
sock.connect((plugin_ssh_config["hostname"], plugin_ssh_config["port"]))
transport_sock = sock
while config_chain:
__create_and_connect_transport(transport_sock, plugin_ssh_config["username"], plugin_ssh_config["password"], plugin_ssh_config["identityfile"])
transport_sock = self._client._transport.open_session()
transport_sock.exec_command(plugin_ssh_config["proxy_command"])
plugin_ssh_config = config_chain.pop()
__create_and_connect_transport(transport_sock, plugin_ssh_config["username"], plugin_ssh_config["password"], plugin_ssh_config["identityfile"])
except Exception as e:
print(e)
raise Exception("connect failed!")