當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。