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

Python telepath.openurl函数代码示例

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

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



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


示例16: main

def main(argv, outp=s_output.stdout):

    pars = argparse.ArgumentParser(prog='cryo.cat', description='display data items from a cryo cell')
    pars.add_argument('cryotank', help='The telepath URL for the remote cryotank.')
    pars.add_argument('--offset', default=0, type=int, help='Begin at offset index')
    pars.add_argument('--size', default=10, type=int, help='How many items to display')
    pars.add_argument('--omit-offset', default=False, action='store_true', help='Output raw items with no offsets.')
    # TODO: synapse.tools.cryo.list <cryocell>
    #pars.add_argument('--list', default=False, action='store_true', help='List tanks in the remote cell and return')
    group = pars.add_mutually_exclusive_group()
    group.add_argument('--jsonl', action='store_true', help='Input/Output items in jsonl format')
    group.add_argument('--msgpack', action='store_true', help='Input/Output items in msgpack format')
    pars.add_argument('--verbose', '-v', default=False, action='store_true', help='Verbose output')
    pars.add_argument('--ingest', '-i', default=False, action='store_true',
                      help='Reverses direction: feeds cryotank from stdin in msgpack or jsonl format')

    opts = pars.parse_args(argv)

    if opts.verbose:
        logger.setLevel(logging.INFO)

    if opts.ingest and not opts.jsonl and not opts.msgpack:
        outp.printf('Must specify exactly one of --jsonl or --msgpack if --ingest is specified')
        return 1

    logger.info(f'connecting to: {opts.cryotank}')

    with s_telepath.openurl(opts.cryotank) as tank:

        if opts.ingest:

            if opts.msgpack:
                items = list(s_msgpack.iterfd(sys.stdin.buffer))
                tank.puts(items)
                return 0

            items = [json.loads(l) for l in sys.stdin]
            tank.puts(items)
            return 0

        for item in tank.slice(opts.offset, opts.size):

            if opts.jsonl:
                outp.printf(json.dumps(item[1], sort_keys=True))

            elif opts.msgpack:
                sys.stdout.buffer.write(s_msgpack.en(item[1]))

            else:
                outp.printf(pprint.pformat(item))
    return 0
开发者ID:vivisect,项目名称:synapse,代码行数:51,代码来源:cat.py


示例17: test_link_local

    def test_link_local(self):
        self.thisHostMustNot(platform='windows')
        name = guid()

        dmon = s_daemon.Daemon()
        dmon.share('foo',FooBar())

        link = dmon.listen('local://%s' % (name,))

        prox = s_telepath.openurl('local://%s/foo' % name)

        self.assertEqual( prox.foo(), 'bar' )

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


示例18: main

def main(argv, outp=s_output.stdout):

    pars = argparse.ArgumentParser(prog='cryo.list', description='List tanks within a cryo cell.')
    pars.add_argument('cryocell', nargs='+', help='Telepath URLs to cryo cells.')

    opts = pars.parse_args(argv)

    for url in opts.cryocell:

        outp.printf(url)

        with s_telepath.openurl(url) as cryo:

            for name, info in cryo.list():

                outp.printf(f'    {name}: {info}')
开发者ID:vivisect,项目名称:synapse,代码行数:16,代码来源:list.py


示例19: getSwarmEnv

    def getSwarmEnv(self):
        tenv = TestEnv()

        core0 = s_cortex.openurl("ram://")
        core1 = s_cortex.openurl("ram://")

        tenv.add("core0", core0, fini=True)
        tenv.add("core1", core1, fini=True)

        tufo0 = core0.formTufoByProp("foo:bar", "baz", vvv="visi")
        tufo1 = core0.formTufoByProp("foo:bar", "faz", vvv="visi")
        tufo2 = core1.formTufoByProp("foo:bar", "lol", vvv="visi")
        tufo3 = core1.formTufoByProp("foo:bar", "hai", vvv="visi")

        tufo4 = core0.formTufoByProp("zzz:woot", 10, vvv="visi")
        tufo5 = core1.formTufoByProp("zzz:woot", 12, vvv="romp")

        tenv.add("tufo0", tufo0)
        tenv.add("tufo1", tufo1)
        tenv.add("tufo2", tufo2)
        tenv.add("tufo3", tufo3)

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

        tenv.add("link", link)
        tenv.add("dmon", dmon, fini=True)

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

        svcbus = s_service.SvcBus()
        tenv.add("svcbus", svcbus, fini=True)

        dmon.share("syn.svcbus", svcbus)

        svcrmi = s_telepath.openurl("tcp://127.0.0.1/syn.svcbus", port=port)
        tenv.add("svcrmi", svcrmi, fini=True)

        s_service.runSynSvc("cortex", core0, svcrmi, tags=("hehe.haha",))
        s_service.runSynSvc("cortex", core1, svcrmi, tags=("hehe.hoho",))

        runt = s_runtime.Runtime(svcrmi)

        tenv.add("runt", runt, fini=True)

        return tenv
开发者ID:williballenthin,项目名称:synapse,代码行数:46,代码来源:test_swarm_runtime.py


示例20: getSwarmEnv

    def getSwarmEnv(self):
        tenv = TestEnv()

        core0 = s_cortex.openurl('ram://')
        core1 = s_cortex.openurl('ram://')

        tenv.add('core0',core0,fini=True)
        tenv.add('core1',core1,fini=True)

        tufo0 = core0.formTufoByProp('foo:bar','baz',vvv='visi')
        tufo1 = core0.formTufoByProp('foo:bar','faz',vvv='visi')
        tufo2 = core1.formTufoByProp('foo:bar','lol',vvv='visi')
        tufo3 = core1.formTufoByProp('foo:bar','hai',vvv='visi')

        tufo4 = core0.formTufoByProp('zzz:woot',10,vvv='visi')
        tufo5 = core1.formTufoByProp('zzz:woot',12,vvv='romp')

        tenv.add('tufo0',tufo0)
        tenv.add('tufo1',tufo1)
        tenv.add('tufo2',tufo2)
        tenv.add('tufo3',tufo3)

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

        tenv.add('link',link)
        tenv.add('dmon',dmon,fini=True)

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

        svcbus = s_service.SvcBus()
        tenv.add('svcbus',svcbus,fini=True)

        dmon.share('syn.svcbus',svcbus)

        svcrmi = s_telepath.openurl('tcp://127.0.0.1/syn.svcbus', port=port)
        tenv.add('svcrmi',svcrmi,fini=True)

        s_service.runSynSvc('cortex',core0,svcrmi,tags=('hehe.haha',))
        s_service.runSynSvc('cortex',core1,svcrmi,tags=('hehe.hoho',))

        runt = s_runtime.Runtime(svcrmi)

        tenv.add('runt',runt,fini=True)

        return tenv
开发者ID:jhsmith,项目名称:synapse,代码行数:46,代码来源:test_swarm_runtime.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python types.get_domain_from_id函数代码示例发布时间:2022-05-27
下一篇:
Python presence.UserPresenceState类代码示例发布时间: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