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


Python Transport.set_subsystem_handler方法代码示例

本文整理汇总了Python中paramiko.Transport.set_subsystem_handler方法的典型用法代码示例。如果您正苦于以下问题:Python Transport.set_subsystem_handler方法的具体用法?Python Transport.set_subsystem_handler怎么用?Python Transport.set_subsystem_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paramiko.Transport的用法示例。


在下文中一共展示了Transport.set_subsystem_handler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sftp_server

# 需要导入模块: from paramiko import Transport [as 别名]
# 或者: from paramiko.Transport import set_subsystem_handler [as 别名]
def sftp_server():
    """
    Set up an in-memory SFTP server thread. Yields the client Transport/socket.

    The resulting client Transport (along with all the server components) will
    be the same object throughout the test session; the `sftp` fixture then
    creates new higher level client objects wrapped around the client
    Transport, as necessary.
    """
    # Sockets & transports
    socks = LoopSocket()
    sockc = LoopSocket()
    sockc.link(socks)
    tc = Transport(sockc)
    ts = Transport(socks)
    # Auth
    host_key = RSAKey.from_private_key_file(_support("test_rsa.key"))
    ts.add_server_key(host_key)
    # Server setup
    event = threading.Event()
    server = StubServer()
    ts.set_subsystem_handler("sftp", SFTPServer, StubSFTPServer)
    ts.start_server(event, server)
    # Wait (so client has time to connect? Not sure. Old.)
    event.wait(1.0)
    # Make & yield connection.
    tc.connect(username="slowdive", password="pygmalion")
    yield tc
开发者ID:gaudenz,项目名称:paramiko,代码行数:30,代码来源:conftest.py

示例2: MyTSFTPRequestHandler

# 需要导入模块: from paramiko import Transport [as 别名]
# 或者: from paramiko.Transport import set_subsystem_handler [as 别名]
class MyTSFTPRequestHandler(SocketServer.BaseRequestHandler):
    timeout = 60
    auth_timeout = 60

    def setup(self):
        self.transport = Transport(self.request)
        self.transport.load_server_moduli()
        so = self.transport.get_security_options()
        so.digests = ('hmac-sha1', )
        so.compression = ('[email protected]', 'none')
        self.transport.add_server_key(self.server.host_key)
        self.transport.set_subsystem_handler(
            'sftp', MyTSFTPServer, MyTSFTPServerInterface)

    def handle(self):
        self.transport.start_server(server=MyTServerInterface())

    def handle_timeout(self):
        self.transport.close()
开发者ID:mytardis,项目名称:mytardis,代码行数:21,代码来源:sftp.py


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