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


Python telepath.openurl函数代码示例

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


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

示例1: test_daemon_on

    def test_daemon_on(self):

        class Foo:
            def bar(self):
                return 'baz'

        dmon = s_daemon.Daemon()
        link = dmon.listen('tcp://127.0.0.1:0/')

        bus = s_eventbus.EventBus()
        foo = Foo()

        dmon.share('bus', bus)
        dmon.share('foo', foo)

        port = link[1].get('port')

        bprox = s_telepath.openurl('tcp://127.0.0.1/bus', port=port)
        fprox = s_telepath.openurl('tcp://127.0.0.1/foo', port=port)

        evt = threading.Event()
        def woot(mesg):
            evt.set()

        bprox.on('woot', woot)
        fprox.on('woot', woot)

        bus.fire('woot')

        evt.wait(timeout=2)

        fprox.off('woot', woot)

        self.assertTrue( evt.is_set() )
开发者ID:imjonsnooow,项目名称:synapse,代码行数:34,代码来源:test_daemon.py

示例2: test_daemon_on

    def test_daemon_on(self):
        class Foo:
            def bar(self):
                return "baz"

        dmon = s_daemon.Daemon()
        link = dmon.listen("tcp://127.0.0.1:0/")

        bus = s_eventbus.EventBus()
        foo = Foo()

        dmon.share("bus", bus)
        dmon.share("foo", foo)

        port = link[1].get("port")

        bprox = s_telepath.openurl("tcp://127.0.0.1/bus", port=port)
        fprox = s_telepath.openurl("tcp://127.0.0.1/foo", port=port)

        evt = threading.Event()

        def woot(mesg):
            evt.set()

        bprox.on("woot", woot)
        fprox.on("woot", woot)

        bus.fire("woot")

        evt.wait(timeout=2)

        fprox.off("woot", woot)

        self.assertTrue(evt.is_set())
开发者ID:williballenthin,项目名称:synapse,代码行数:34,代码来源:test_daemon.py

示例3: getHiveEnv

    def getHiveEnv(self):

        #FIXME remove when synapse link local:// supports windows
        self.thisHostMustNot(platform='windows')

        dmon = s_daemon.Daemon()
        queen = s_hivemind.Queen()

        dmon.share('syn.queen', queen)
        link = dmon.listen('tcp://127.0.0.1:0/')

        port = link[1].get('port')
        qprox = s_telepath.openurl('tcp://127.0.0.1/syn.queen', port=port)

        hive = s_hivemind.Hive(qprox, size=32)
        drone = s_hivemind.Drone(qprox, size=2)

        env = TestEnv()

        # order matters for fini calls...
        env.add('hive', hive, fini=True)
        env.add('drone', drone, fini=True)

        env.add('qprox', qprox, fini=True)
        env.add('queen', queen, fini=True)

        env.add('dmon', dmon, fini=True)

        return env
开发者ID:jhsmith,项目名称:synapse,代码行数:29,代码来源:test_hivemind.py

示例4: test_telepath_reconnect

    def test_telepath_reconnect(self):
        tenv = self.getFooEnv()

        port = tenv.link[1].get('port')
        prox = s_telepath.openurl('tcp://127.0.0.1/foo', port=port)

        url = 'tcp://127.0.0.1:%d/foo' % (port,)
        self.assertEqual( prox.bar(10,20), 30 )

        waiter = self.getTestWait(prox, 1, 'tele:sock:init')

        # shut down the daemon
        tenv.dmon.fini()

        dmon = s_daemon.Daemon()
        dmon.share('foo',Foo())
        dmon.listen(url)

        waiter.wait()

        self.assertEqual( prox.bar(10,20), 30 )

        prox.fini()
        dmon.fini()
        tenv.fini()
开发者ID:jhsmith,项目名称:synapse,代码行数:25,代码来源:test_telepath.py

示例5: test_telepath_fakesync

    def test_telepath_fakesync(self):
        env = self.getFooEnv()
        port = env.link[1].get('port')

        class DeadLock(s_eventbus.EventBus):

            def hork(self):
                self.fire('foo:bar')

            def bar(self, x, y):
                return x + y

        dead = DeadLock()
        env.dmon.share('dead',dead)

        data = {}
        evt = threading.Event()

        prox = s_telepath.openurl('tcp://127.0.0.1/dead', port=port)
        def foobar(mesg):
            data['foobar'] = prox.bar(10,20)
            evt.set()

        prox.on('foo:bar', foobar)

        prox.hork()

        evt.wait(timeout=2)

        self.assertEqual( data.get('foobar'), 30 )

        prox.fini()
        dead.fini()
        env.fini()
开发者ID:imjonsnooow,项目名称:synapse,代码行数:34,代码来源:test_telepath.py

示例6: test_cell_nonstandard_admin

    async def test_cell_nonstandard_admin(self):
        boot = {
            'auth:admin': 'pennywise:cottoncandy',
            'type': 'echoauth',
        }
        pconf = {'user': 'pennywise', 'passwd': 'cottoncandy'}

        with self.getTestDir('cellauth') as dirn:

            s_common.yamlsave(boot, dirn, 'boot.yaml')
            async with await EchoAuth.anit(dirn) as echo:

                echo.insecure = False

                # start a regular network listener so we can auth
                host, port = await echo.dmon.listen('tcp://127.0.0.1:0/')
                async with await s_telepath.openurl(f'tcp://127.0.0.1:{port}/', **pconf) as proxy:

                    self.true(await proxy.isadmin())
                    self.true(await proxy.allowed(('hehe', 'haha')))

                url = f'tcp://[email protected]:{port}/'
                await self.asyncraises(s_exc.AuthDeny, s_telepath.openurl(url))

        # Ensure the cell and its auth have been fini'd
        self.true(echo.isfini)
        self.true(echo.auth.isfini)
        self.true(echo.auth.getUserByName('root').isfini)
        self.true(echo.auth.getUserByName('pennywise').isfini)
开发者ID:vivisect,项目名称:synapse,代码行数:29,代码来源:test_lib_cell.py

示例7: test_service_base

    def test_service_base(self):
        sbus = s_service.SvcBus()

        dmon = s_daemon.Daemon()
        dmon.share('syn.svcbus', sbus)

        link = dmon.listen('tcp://127.0.0.1:0/')

        port = link[1].get('port')

        prox = s_telepath.openurl('tcp://127.0.0.1/syn.svcbus', port=port)

        woot = Woot()

        s_service.runSynSvc('syn.woot', woot, prox)

        svcs = prox.getSynSvcs()

        self.assertEqual( len(svcs), 1 )
        self.assertEqual( svcs[0][1].get('name'), 'syn.woot' )

        dyntask = s_async.newtask('foo',10,y=30)

        job = prox.callx(svcs[0][0], dyntask)
        self.assertEqual( prox.syncjob(job), 40 )

        prox.fini()
        dmon.fini()
        sbus.fini()
开发者ID:k1derly-fe,项目名称:synapse,代码行数:29,代码来源:test_service.py

示例8: test_telepath_reshare

    def test_telepath_reshare(self):
        env0 = self.getFooEnv()
        env1 = self.getFooEnv()

        port = env0.link[1].get('port')
        prox0 = s_telepath.openurl('tcp://127.0.0.1/foo', port=port)

        env1.dmon.share('bar', prox0)

        port = env1.link[1].get('port')
        prox1 = s_telepath.openurl('tcp://127.0.0.1/bar', port=port)

        self.assertEqual( prox1.bar(33,44), 77 )

        env0.fini()
        env1.fini()
开发者ID:imjonsnooow,项目名称:synapse,代码行数:16,代码来源:test_telepath.py

示例9: test_telepath_nosuchobj

    def test_telepath_nosuchobj(self):
        dmon,link = self.getFooServ()
        port = link[1].get('port')

        newp = s_telepath.openurl('tcp://localhost:%d/newp' % (port,))
        self.assertRaises( JobErr, newp.foo )

        dmon.fini()
开发者ID:imjonsnooow,项目名称:synapse,代码行数:8,代码来源:test_telepath.py

示例10: test_telepath_push

    def test_telepath_push(self):
        env = self.getFooEnv()
        port = env.link[1].get('port')

        prox0 = s_telepath.openurl('tcp://127.0.0.1/', port=port)
        prox0.push('foo1', Foo() )

        prox1 = s_telepath.openurl('tcp://127.0.0.1/foo1', port=port)

        self.eq( prox1.bar(10,20), 30 )

        prox0.fini()

        self.assertRaises( s_async.JobErr, prox1.bar, 10, 20 )

        prox1.fini()

        env.fini()
开发者ID:imjonsnooow,项目名称:synapse,代码行数:18,代码来源:test_telepath.py

示例11: getNeuNet

    def getNeuNet(self):

        env = TestEnv()

        dmon = s_daemon.Daemon()
        env.add('dmon',dmon,fini=True)

        link = dmon.listen('tcp://127.0.0.1:0/')

        neu0 = s_neuron.Neuron()

        env.add('neu0', s_neuron.Neuron(), fini=True)
        env.add('neu1', s_neuron.Neuron(), fini=True)
        env.add('neu2', s_neuron.Neuron(), fini=True)

        env.dmon.share('neu0', env.neu0)
        env.dmon.share('neu1', env.neu1)
        env.dmon.share('neu2', env.neu2)

        #dmon.onfini( neu0.fini )
        #dmon.onfini( neu1.fini )
        #dmon.onfini( neu2.fini )

        #dmon.share('neu0',neu0)
        #dmon.share('neu1',neu1)
        #dmon.share('neu2',neu2)

        port = link[1].get('port')

        env.add('neup0', s_telepath.openurl('tcp://127.0.0.1/neu0', port=port), fini=True)
        env.add('neup1', s_telepath.openurl('tcp://127.0.0.1/neu1', port=port), fini=True)
        env.add('neup2', s_telepath.openurl('tcp://127.0.0.1/neu2', port=port), fini=True)

        wai0 = TestWaiter(env.neu1, 1, 'neu:link:init')
        env.neu0.link( env.neup1 )
        wai0.wait()

        wai0 = TestWaiter(env.neu1, 1, 'neu:link:init')
        env.neu0.link( env.neup2 )
        wai0.wait()

        return env
开发者ID:jhsmith,项目名称:synapse,代码行数:42,代码来源:test_neuron.py

示例12: openurl

def openurl(url, **opts):
    '''
    Open a remote service bus and return a SvcProxy class.

    Example:

        svcprox = openbus('tcp://svcbus.com/mybus')

    '''
    svcbus = s_telepath.openurl(url,**opts)
    return SvcProxy(svcbus)
开发者ID:williballenthin,项目名称:synapse,代码行数:11,代码来源:service.py

示例13: main

def main(argv):

    p = argparse.ArgumentParser()
    p.add_argument('--size', default=mproc.cpu_count(), type=int, help='Number of parallel work units to run')
    p.add_argument('queenurl', help='synapse link URL to connect to queen')

    args = p.parse_args(argv)

    queen = s_telepath.openurl(args.queenurl)
    drone = s_hivemind.Drone(queen, size=args.size)

    drone.main()
开发者ID:jhsmith,项目名称:synapse,代码行数:12,代码来源:droned.py

示例14: test_telepath_chop

    def test_telepath_chop(self):

        dmon,link = self.getFooServ()

        port = link[1].get('port')

        foo = s_telepath.openurl('tcp://localhost:%d/foo' % (port,))

        self.assertEqual( foo.bar(10,20), 30 )

        foo.fini()
        dmon.fini()
开发者ID:imjonsnooow,项目名称:synapse,代码行数:12,代码来源:test_telepath.py

示例15: test_telepath_push

    def test_telepath_push(self):

        # override default timeout=None for tests
        with s_threads.ScopeLocal(syntimeout=5):

            env = self.getFooEnv()
            port = env.link[1].get('port')

            prox0 = s_telepath.openurl('tcp://127.0.0.1/', port=port)
            prox0.push('foo1', Foo() )

            prox1 = s_telepath.openurl('tcp://127.0.0.1/foo1', port=port)

            self.eq( prox1.bar(10,20), 30 )

            prox0.fini()

            self.assertRaises( s_async.JobErr, prox1.bar, 10, 20 )

            prox1.fini()

            env.fini()
开发者ID:williballenthin,项目名称:synapse,代码行数:22,代码来源:test_telepath.py


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