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


Python SSHCommandClientEndpoint.existingConnection方法代码示例

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


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

示例1: create

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
    def create(self):
        """
        Create and return a new L{SSHCommandClientEndpoint} using the
        C{existingConnection} constructor.
        """
        factory = Factory()
        factory.protocol = Protocol
        connected = self.endpoint.connect(factory)

        # Please, let me in.  This kinda sucks.
        channelLookup = self.realm.channelLookup.copy()
        try:
            self.realm.channelLookup[b'session'] = WorkingExecSession

            server, client, pump = self.connectedServerAndClient(
                self.factory, self.reactor.tcpClients[0][2])

        finally:
            self.realm.channelLookup.clear()
            self.realm.channelLookup.update(channelLookup)

        self._server = server
        self._client = client
        self._pump = pump

        protocol = self.successResultOf(connected)
        connection = protocol.transport.conn
        return SSHCommandClientEndpoint.existingConnection(
            connection, b"/bin/ls -l")
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:31,代码来源:test_endpoints.py

示例2: spawnProcess

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
 def spawnProcess(self, protocol, command):
     factory = Factory()
     factory.protocol = lambda: _CommandProtocol(protocol)
     e = SSHCommandClientEndpoint.existingConnection(
             self.master_proto.transport.conn, command)
     d = e.connect(factory)
     return d.addCallback(self._commandStarted)
开发者ID:moldit,项目名称:mold,代码行数:9,代码来源:ssh.py

示例3: executeNewCommand

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
    def executeNewCommand(self, line):
        factory = Factory()
        factory.protocol = MyProtocol

        e = SSHCommandClientEndpoint.existingConnection(self.ssh_conn,
                                                        line.strip())
        d = e.connect(factory)
        d.addCallback(self.protoStarted)
开发者ID:moldit,项目名称:mold,代码行数:10,代码来源:ssh2.py

示例4: exec_command

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
    def exec_command(self, command):
        conn = self.transport.conn
        factory = protocol.Factory()
        factory.protocol = SingleCommandProtocol

        e = SSHCommandClientEndpoint.existingConnection(conn, command)
        d = e.connect(factory)
        d.addCallback(lambda p: p.finished)
        return d
开发者ID:GaretJax,项目名称:ipd,代码行数:11,代码来源:ssh.py

示例5: _spawnProcess

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
 def _spawnProcess(self, protocol, command):
     vvvv('ACTUALLY SPAWN: %r' % (command,))
     factory = Factory()
     factory.protocol = lambda: _CommandProtocol(protocol)
     e = SSHCommandClientEndpoint.existingConnection(
             self.master_proto.transport.conn,
             command)
     d = e.connect(factory)
     vvvv('STARTING')
     return d.addCallbacks(self._commandStarted, self._commandFailedToStart)
开发者ID:iffy,项目名称:ansible,代码行数:12,代码来源:tx.py

示例6: perform_run

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
 def perform_run(dispatcher, intent):
     context.bind(
         message_type="flocker.provision.ssh:run",
         command=intent.log_command_filter(intent.command),
     ).write()
     endpoint = SSHCommandClientEndpoint.existingConnection(
         connection, intent.command)
     d = Deferred()
     connectProtocol(endpoint, CommandProtocol(
         deferred=d, context=context))
     return d
开发者ID:wangbinxiang,项目名称:flocker,代码行数:13,代码来源:_conch.py

示例7: gotConnection

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
    def gotConnection(proto):
        conn = proto.transport.conn

        for i in range(50):
            factory = Factory()
            factory.protocol = PrinterProtocol
            factory.done = Deferred()
            done.append(factory.done)

            e = SSHCommandClientEndpoint.existingConnection(
                conn, b"/bin/echo %d" % (i,))
            yield e.connect(factory)
开发者ID:wellbehavedsoftware,项目名称:wbs-graphite,代码行数:14,代码来源:echoclient_shared_ssh.py

示例8: fork

# 需要导入模块: from twisted.conch.endpoints import SSHCommandClientEndpoint [as 别名]
# 或者: from twisted.conch.endpoints.SSHCommandClientEndpoint import existingConnection [as 别名]
    def fork(self, command, args=(), env={}, path=None, timeout=3600):
        if not self.connection:
            log.msg("Connection to %s not yet ready" % (
                self.hostname,))

            return defer.maybeDeferred(lambda: (None, "SSH not ready", 255))

        if env:
            env = ' '.join('%s=%s' % (k, v) for k, v in env.items()) + ' '
        else:
            env = ''

        if args:
            args = ' ' + ' '.join(args)
        else:
            args = ''

        e = SSHCommandClientEndpoint.existingConnection(self.connection,
                (env + command + args).encode())

        factory = protocol.Factory()
        factory.protocol = SSHCommandProtocol
        factory.done = defer.Deferred()

        def finished(result):
            stdout, stderr, code = result
            return (stdout.read(), stderr.read(), code)

        factory.done.addCallback(finished)

        def connected(connection):
            # Be nice if Conch exposed this better...
            connection.transport.extReceived = connection.extReceived
            return factory.done

        return e.connect(factory).addCallback(connected)
开发者ID:calston,项目名称:tensor,代码行数:38,代码来源:ssh.py


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