示例#1
0
文件: shell.py 项目: kbni/miso
def create_shell(with_files, exit_after=False):
    config = dict(**EnvYAML('config.yml'))
    banner = f'Nameko Python {sys.version}\nBroker is {config[AMQP_URI_CONFIG_KEY]}'
    n = make_nameko_helper(config)
    ctx = {'n': n, 'rpc': n.rpc, 'config': config, 'os': os, 'sys': sys, 'json': json, 'yaml': yaml}
    ctx['authed'] = ShellHelper(config, context_data={'miso_auth_token': 'bleh'})
    for fn in with_files:
        with open(fn, 'r') as fh:
            print(f'executing {fn}')
            exec(fh.read(), ctx)
    if not exit_after:
        runner = ShellRunner(banner, ctx)
        runner.start_shell(name=None)
示例#2
0
def main():
    setup_yaml_parser()
    with open("/app/config.yaml") as fle:
        config = yaml.unsafe_load(fle)
    if len(sys.argv) > 1:
        config[AMQP_URI_CONFIG_KEY] = sys.argv[1]

    try:
        ctx = {}
        ctx['n'] = make_nameko_helper(config)
        ctx['maiev'] = ctx['n'].rpc

        c = get_config()
        c.IPCompleter.debug = True
        c.IPCompleter.use_jedi = False
        start_ipython(
            [],
            banner1="maiev shell to %s\nuse maiev.service_name.method(args)" % config[AMQP_URI_CONFIG_KEY],
            user_ns=ctx,
            config=c,
        )
    except Exception:
        traceback.print_exc()
        print("failed to start shell to %s" % config[AMQP_URI_CONFIG_KEY])
示例#3
0
def test_helper_module(rabbit_config):
    helper = make_nameko_helper(rabbit_config)
    assert isinstance(helper.rpc, ClusterProxy)
    helper.disconnect()
示例#4
0
def test_helper_module(rabbit_config):
    helper = make_nameko_helper(rabbit_config)
    assert isinstance(helper.rpc, ClusterProxy)
    helper.disconnect()
示例#5
0
from nameko.cli.shell import make_nameko_helper
from nameko.constants import AMQP_URI_CONFIG_KEY

import settings

config = {AMQP_URI_CONFIG_KEY: settings.AMQP_URI}

n = make_nameko_helper(config)

n.rpc.syncer_service.run()