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


Python reactor.connectUNIX函数代码示例

本文整理汇总了Python中twisted.internet.reactor.connectUNIX函数的典型用法代码示例。如果您正苦于以下问题:Python connectUNIX函数的具体用法?Python connectUNIX怎么用?Python connectUNIX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

def main():
    parser = OptionParser()
    parser.add_option(
        "--socket",
        help="UNIX socket where melissi client listens",
        default=os.path.expanduser("~/.config/melisi/melisi.sock"),
    )
    (options, args) = parser.parse_args()

    commands = {
        "auth": auth,
        "disconnect": disconnect,
        "connect": connect,
        "register": register,
        "checkbusy": checkbusy,
        "sethost": sethost,
        "deleteuser": deleteuser,
        "addshare": addshare,
        "removeshare": removeshare,
    }

    if len(args) < 1:
        usage(commands)
        sys.exit(0)

    try:
        commands[args[0]](args[1:])
    except KeyError:
        usage(commands)
        sys.exit(1)

    melisi_commander = MelisiCommander(command_list)
    reactor.connectUNIX(options.socket, melisi_commander)
    reactor.callLater(2, _timeout)
    reactor.run()
开发者ID:akatsoulas,项目名称:client,代码行数:35,代码来源:cmelissi.py

示例2: testDumber

 def testDumber(self):
     filename = tempfile.mktemp()
     l = reactor.listenUNIX(filename, Factory())
     reactor.connectUNIX(filename, TestClientFactory())
     for i in xrange(100):
         reactor.iterate()
     l.stopListening()
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:test_unix.py

示例3: test_dumber

    def test_dumber(self):
        """
        L{IReactorUNIX.connectUNIX} can be used to connect a client to a server
        started with L{IReactorUNIX.listenUNIX}.
        """
        filename = self.mktemp()
        serverFactory = MyServerFactory()
        serverConnMade = defer.Deferred()
        serverFactory.protocolConnectionMade = serverConnMade
        unixPort = reactor.listenUNIX(filename, serverFactory)
        self.addCleanup(unixPort.stopListening)
        clientFactory = MyClientFactory()
        clientConnMade = defer.Deferred()
        clientFactory.protocolConnectionMade = clientConnMade
        reactor.connectUNIX(filename, clientFactory)
        d = defer.gatherResults([serverConnMade, clientConnMade])
        def allConnected(args):
            serverProtocol, clientProtocol = args
            # Incidental assertion which may or may not be redundant with some
            # other test.  This probably deserves its own test method.
            self.assertEqual(clientFactory.peerAddresses,
                             [address.UNIXAddress(filename)])

            clientProtocol.transport.loseConnection()
            serverProtocol.transport.loseConnection()
        d.addCallback(allConnected)
        return d
开发者ID:marcelpetersen,项目名称:localnews,代码行数:27,代码来源:test_unix.py

示例4: connectUNIX

 def connectUNIX(self, sock_path):
     if not self.factory:
         self.factory = pb.PBClientFactory()
         self.factory.clientConnectionFailed = self._onConnectionFailed
         self.factory.clientConnectionLost = self._onConnectionLost
     reactor.connectUNIX(sock_path)
     self.factory.getRootObject().addCallbacks(self.connected, self.onError)
开发者ID:HapPiNeHsSs,项目名称:hideout,代码行数:7,代码来源:pbclient.py

示例5: startFactory

    def startFactory(self):
        """Tell the other end that we are done starting up.
        """
        # Import reactor here to avoid installing default at startup
        from twisted.internet import reactor

        reactor.connectUNIX("zomne_startup_complete.socket", NotificationFactory())
开发者ID:jonathanj,项目名称:nevow,代码行数:7,代码来源:zomnesrv.py

示例6: listen

 def listen(self, reactor):
   if self.simulate:
     reactor.connectUNIX(self.get_simsocket(self.uri), PeerFactory(peer), timeout = 2)
     self.debug("Listening at", self.get_simsocket(self.uri))
   else:
     reactor.listenTCP(self.port, ServerFactory(self, self.serversession), interface = self.host)
     self.debug("Listening at", self.uri)
开发者ID:udoprog,项目名称:metap2p,代码行数:7,代码来源:server.py

示例7: render

    def render(self, request):
        """Render this request, from my server.

        This will always be asynchronous, and therefore return NOT_DONE_YET.
        It spins off a request to the pb client, and either adds it to the list
        of pending issues or requests it immediately, depending on if the
        client is already connected.
        """
        if not self.publisher:
            self.pending.append(request)
            if not self.waiting:
                self.waiting = 1
                bf = pb.PBClientFactory()
                timeout = 10
                if self.host == "unix":
                    reactor.connectUNIX(self.port, bf, timeout)
                else:
                    reactor.connectTCP(self.host, self.port, bf, timeout)
                d = bf.getRootObject()
                d.addCallbacks(self.connected, self.notConnected)

        else:
            i = Issue(request)
            self.publisher.callRemote('request', request).addCallbacks(i.finished, i.failed)
        return server.NOT_DONE_YET
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:25,代码来源:distrib.py

示例8: connect

def connect(host, port, options, verifyHostKey, userAuthObject):
    if options['nocache']: 
        return defer.fail(ConchError('not using connection caching'))
    d = defer.Deferred()
    filename = os.path.expanduser("~/.conch-%s-%s-%i" % (userAuthObject.user, host, port))
    factory = SSHUnixClientFactory(d, options, userAuthObject)
    reactor.connectUNIX(filename, factory, timeout=2, checkPID=1)
    return d
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:8,代码来源:unix.py

示例9: setUp

 def setUp(self):
     sock = self.mktemp()
     serverfactory = DummyCacheServer()
     self.server = reactor.listenUNIX(sock, serverfactory)
     deferred = defer.Deferred()
     self.client = protocol.RRDCacheClient(deferred, True)
     reactor.connectUNIX(sock, self.client)
     return deferred
开发者ID:jordane,项目名称:nagcat,代码行数:8,代码来源:test_protocol.py

示例10: do_connect

def do_connect(listener, reconnect = False):
    if not hasattr(socket, 'AF_UNIX') or common.config.getboolean('Client', 'force_tcp'):
        logging.info('Open tcp port')
        reactor.connectTCP('localhost', common.config.getint('Server', 'port'), ConnectionFactory(listener, reconnect))
    else:
        logging.info('Open file socket')
        reactor.connectUNIX(common.config.get('Server', 'file'), ConnectionFactory(listener, reconnect))
    logging.info("Client started")
开发者ID:kvj,项目名称:mp-twisted,代码行数:8,代码来源:clientconnection.py

示例11: testMode

 def testMode(self):
     filename = tempfile.mktemp()
     l = reactor.listenUNIX(filename, Factory(), mode = 0600)
     self.assertEquals(stat.S_IMODE(os.stat(filename)[0]), 0600)
     reactor.connectUNIX(filename, TestClientFactory())
     for i in xrange(100):
         reactor.iterate()
     l.stopListening()
开发者ID:fxia22,项目名称:ASM_xf,代码行数:8,代码来源:test_unix.py

示例12: connect

 def connect(self):
     if self._node["type"] == "tcp":
         reactor.connectTCP(self._node["host"], self._node["port"], self)
     elif self._node["type"] == "unix":
         reactor.connectUNIX(self._node["addr"], self)
     else:
         log.err("Unknown connect type")
         
     self.getRootObject().addCallback(self._proxy.insert, self._node["name"])
开发者ID:ProgramLeague,项目名称:Castle-Online,代码行数:9,代码来源:nodes.py

示例13: makeUnixConnection

def makeUnixConnection(path, poolsize, reconnect, isLazy):
    factory = TarantoolFactory(poolsize, isLazy, UnixConnectionHandler)
    factory.continueTrying = reconnect
    for x in xrange(poolsize):
        reactor.connectUNIX(path, factory)

    if isLazy:
        return factory.handler
    else:
        return factory.deferred
开发者ID:zlobspb,项目名称:txtarantool,代码行数:10,代码来源:txtarantool.py

示例14: _run

def _run(config, args):
    factory = pb.PBClientFactory()
    reactor.connectUNIX(config.socket, factory)
    try:
        perspective = yield factory.login(UsernamePassword("guest", "guest"))
        yield perspective.callRemote('add_dns', args[0], args[1], int(args[2]))
        print "Record added"
    except Exception as e:
        print "Error: ", str(e)

    reactor.stop()
开发者ID:isotoma,项目名称:badgerproxy,代码行数:11,代码来源:badgerproxyctl.py

示例15: testStoppingServer

 def testStoppingServer(self):
     factory = protocol.ServerFactory()
     factory.protocol = wire.Echo
     t = internet.UNIXServer('echo.skt', factory)
     t.startService()
     t.stopService()
     self.failIf(t.running)
     factory = protocol.ClientFactory()
     d = defer.Deferred()
     factory.clientConnectionFailed = lambda *args: d.callback(None)
     reactor.connectUNIX('echo.skt', factory)
     return d
开发者ID:marcelpetersen,项目名称:localnews,代码行数:12,代码来源:test_application.py


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