• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reactor.connectUNIX函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: attach

    def attach(self, container_id, ticket_id, skip_terminal=False):

        d = defer.Deferred()
        protocol = Attach(d, container_id)

        def stdin_on_input(channel, data):
            protocol.stdin_on_input(data)

        def stdout_write(data):
            self.task_stdout(ticket_id, data)

        def log_write(data):
            self.task_log(ticket_id, b64decode(data))

        try:
            if skip_terminal:
                protocol.stdout_write = log_write
            else:
                protocol.stdout_write = stdout_write

                self.eb.on('task.stdin.%s' % int(ticket_id), stdin_on_input)

            f = AttachFactory(protocol)

            proto, url = self.url.split('://')
            url = url.strip('/')

            print 'url::::::::::::::::'
            print url
            if ':' in url:
                host, port = url.split(':')
            else:
                host = url
                port = 2376 if proto == 'https' else 2375

            if proto == 'https':
                from mcloud.ssl import CtxFactory
                pkey = load_privatekey(FILETYPE_PEM, self.key)
                cert = load_certificate(FILETYPE_PEM, self.crt)
                reactor.connectSSL(host, int(port), f, CtxFactory(pkey, cert))
            else:
                if proto == 'unix':
                    reactor.connectUNIX(host, f)
                else:
                    reactor.connectTCP(host, port, f)


            yield d

        finally:
            if not skip_terminal:
                self.eb.cancel('task.stdin.%s' % int(ticket_id), stdin_on_input)
开发者ID:hydface2,项目名称:mcloud,代码行数:52,代码来源:txdocker.py


示例17: getSomeObjectAt

def getSomeObjectAt(host, port, timeout=None, objname="root"):
    from twisted.internet import defer
    from twisted.spread.pb import Broker, BrokerClientFactory
    d = defer.Deferred()
    b = Broker(1)
    bf = BrokerClientFactory(b)
    my_ObjectRetrieval(b, d, objname)
    if host == "unix":
        # every time you use this, God kills a kitten
        reactor.connectUNIX(port, bf, timeout)
    else:
        reactor.connectTCP(host, port, bf, timeout)
    return d
开发者ID:BillAndersan,项目名称:twisted,代码行数:13,代码来源:pb4client.py


示例18: get_Mpd

def get_Mpd(addr='127.0.0.1', port=6600, cover_dir='/var/lib/mpd/'):
    f = Mpd_factory(cover_dir=cover_dir)
    if addr.startswith('/') or addr.startswith('~'):
        reactor.connectUNIX(addr, f)  # @UndefinedVariable
#         from twisted.internet.endpoints import UNIXClientEndpoint
#         edp = UNIXClientEndpoint(reactor, addr)
#         edp.connect(f)
    else:
        reactor.connectTCP(addr, port, f)  # @UndefinedVariable
#         from twisted.internet.endpoints import TCP4ClientEndpoint
#         edp = TCP4ClientEndpoint(reactor, addr, port)
#         edp.connect(f)

    return None, f
开发者ID:bverdu,项目名称:onDemand,代码行数:14,代码来源:mpd_new.py


示例19: testStoppingServer

 def testStoppingServer(self):
     if not interfaces.IReactorUNIX(reactor, None):
         raise unittest.SkipTest, "This reactor does not support UNIX domain sockets"
     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:Berimor66,项目名称:mythbox,代码行数:14,代码来源:test_application.py


示例20: open

    def open(self, address, pidfile=None):
        """Open connection to rrdcached

        @param address: path to rrdcached's UNIX socket
        @type address: str
        @param pidfile: optionally check rrdcached's pid file
        @type pidfile: str
        """

        deferred = defer.Deferred()
        self._client = protocol.RRDCacheClient(deferred)
        reactor.connectUNIX(address, self._client, checkPID=pidfile)
        self.update = self._update_cache
        return deferred
开发者ID:jordane,项目名称:nagcat,代码行数:14,代码来源:twist.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reactor.crash函数代码示例发布时间:2022-05-27
下一篇:
Python reactor.connectTCP函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap