当前位置: 首页>>代码示例>>Python>>正文


Python transport.Transport方法代码示例

本文整理汇总了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 
开发者ID:ohmyadd,项目名称:wetland,代码行数:20,代码来源:client.py

示例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 
开发者ID:lycclsltt,项目名称:watchmen,代码行数:14,代码来源:client.py

示例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 
开发者ID:lycclsltt,项目名称:watchmen,代码行数:12,代码来源:client.py

示例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 
开发者ID:summerwinter,项目名称:SublimeRemoteGDB,代码行数:14,代码来源:client.py

示例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 
开发者ID:summerwinter,项目名称:SublimeRemoteGDB,代码行数:11,代码来源:client.py

示例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!") 
开发者ID:summerwinter,项目名称:SublimeRemoteGDB,代码行数:50,代码来源:nested_paramiko.py


注:本文中的paramiko.transport.Transport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。