當前位置: 首頁>>代碼示例>>Python>>正文


Python Factory.buildProtocol方法代碼示例

本文整理匯總了Python中twisted.internet.protocol.Factory.buildProtocol方法的典型用法代碼示例。如果您正苦於以下問題:Python Factory.buildProtocol方法的具體用法?Python Factory.buildProtocol怎麽用?Python Factory.buildProtocol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.internet.protocol.Factory的用法示例。


在下文中一共展示了Factory.buildProtocol方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: connectedServerAndClient

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def connectedServerAndClient(self, serverFactory, clientFactory):
        """
        Set up an in-memory connection between protocols created by
        C{serverFactory} and C{clientFactory}.

        @return: A three-tuple.  The first element is the protocol created by
            C{serverFactory}.  The second element is the protocol created by
            C{clientFactory}.  The third element is the L{IOPump} connecting
            them.
        """
        clientProtocol = clientFactory.buildProtocol(None)
        serverProtocol = serverFactory.buildProtocol(None)

        clientTransport = AbortableFakeTransport(
            clientProtocol, isServer=False, hostAddress=self.clientAddress,
            peerAddress=self.serverAddress)
        serverTransport = AbortableFakeTransport(
            serverProtocol, isServer=True, hostAddress=self.serverAddress,
            peerAddress=self.clientAddress)

        pump = connect(
            serverProtocol, serverTransport, clientProtocol, clientTransport)
        return serverProtocol, clientProtocol, pump 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:25,代碼來源:test_endpoints.py

示例2: test_buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def test_buildProtocol(self):
        """
        Once the necessary SSH actions have completed successfully,
        L{SSHCommandClientEndpoint.connect} uses the factory passed to it to
        construct a protocol instance by calling its C{buildProtocol} method
        with an address object representing the SSH connection and command
        executed.
        """
        self.realm.channelLookup[b'session'] = WorkingExecSession
        endpoint = self.create()

        factory = AddressSpyFactory()
        factory.protocol = Protocol

        endpoint.connect(factory)

        server, client, pump = self.finishConnection()

        self.assertIsInstance(factory.address, SSHCommandAddress)
        self.assertEqual(server.transport.getHost(), factory.address.server)
        self.assertEqual(self.user, factory.address.username)
        self.assertEqual(b"/bin/ls -l", factory.address.command) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:24,代碼來源:test_endpoints.py

示例3: test_connectionClosedBeforeSecure

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def test_connectionClosedBeforeSecure(self):
        """
        If the connection closes at any point before the SSH transport layer
        has finished key exchange (ie, gotten to the point where we may attempt
        to authenticate), the L{Deferred} returned by
        L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
        the reason for the lost connection.
        """
        endpoint = SSHCommandClientEndpoint.newConnection(
            self.reactor, b"/bin/ls -l", b"dummy user",
            self.hostname, self.port, knownHosts=self.knownHosts,
            ui=FixedResponseUI(False))

        factory = Factory()
        factory.protocol = Protocol
        d = endpoint.connect(factory)

        transport = StringTransport()
        factory = self.reactor.tcpClients[0][2]
        client = factory.buildProtocol(None)
        client.makeConnection(transport)

        client.connectionLost(Failure(ConnectionDone()))
        self.failureResultOf(d).trap(ConnectionDone) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:26,代碼來源:test_endpoints.py

示例4: buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def buildProtocol(self, address):
        self.address = address
        return Factory.buildProtocol(self, address) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:5,代碼來源:test_endpoints.py

示例5: connect

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def connect(self, factory):
        if self.pump is not None:
            raise Exception("SingleUseMemoryEndpoint was already used")

        try:
            protocol = factory.buildProtocol(MemoryAddress())
        except:
            return fail()
        else:
            self.pump = connect(
                self._server, AbortableFakeTransport(
                    self._server, isServer=True),
                protocol, AbortableFakeTransport(protocol, isServer=False))
            return succeed(protocol) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:16,代碼來源:test_endpoints.py

示例6: buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def buildProtocol(self, addr):
        if addr.host not in self.only_ip and "0.0.0.0" not in self.only_ip:
            return
        return Factory.buildProtocol(self, addr) 
開發者ID:OpenBazaar,項目名稱:OpenBazaar-Server,代碼行數:6,代碼來源:ws.py

示例7: buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def buildProtocol(self, addr):
        if self.status in ("starting up", "generating GUID") and self.only_ip != ["127.0.0.1"]:
            return
        if addr.host not in self.only_ip and "0.0.0.0" not in self.only_ip:
            return
        return Factory.buildProtocol(self, addr) 
開發者ID:OpenBazaar,項目名稱:OpenBazaar-Server,代碼行數:8,代碼來源:heartbeat.py

示例8: buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def buildProtocol(self, addr):
        """
        Implement L{Factory.buildProtocol} to return a wrapper protocol that
        will capture C{connectionLost} notifications.

        @return: a L{Protocol}.
        """
        return _WrappedProtocol(self.legacyFactory.buildProtocol(addr), self) 
開發者ID:apple,項目名稱:ccs-twistedextensions,代碼行數:10,代碼來源:adaptendpoint.py

示例9: buildProtocol

# 需要導入模塊: from twisted.internet.protocol import Factory [as 別名]
# 或者: from twisted.internet.protocol.Factory import buildProtocol [as 別名]
def buildProtocol(self, addr):
        p = Factory.buildProtocol(self, addr)
        p.command_cb = self.command_cb
        return p 
開發者ID:hgascon,項目名稱:pulsar,代碼行數:6,代碼來源:Cli_server_local.py


注:本文中的twisted.internet.protocol.Factory.buildProtocol方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。