示例#1
0
文件: qgl.py 项目: fserena/agora-cli
def query(ctx, q, schema_file, ignore_cycles, cache_file, cache_host, cache_port, cache_db, resource_cache,
          fragment_cache, host, port):
    check_init(ctx)

    q = q.replace("'", '"')
    if cache_file:
        path_parts = cache_file.split('/')
        cache_base = '/'.join(cache_file.split('/')[:-1])
        cache_file = path_parts[-1]

    if resource_cache or fragment_cache:
        remote_cache = all([cache_host, cache_port, cache_db])
        cache = RedisCache(redis_file=None if remote_cache else (cache_file or 'data.db'),
                           base='.agora/store' if not cache_file else cache_base,
                           path='',
                           redis_host=cache_host,
                           redis_db=cache_db,
                           redis_port=cache_port)
    else:
        cache = None

    ctx.obj['gw'].data_cache = cache
    processor = GraphQLProcessor(ctx.obj['gw'], schema_path=schema_file, scholar=fragment_cache, host=host,
                                 port=port, follow_cycles=not ignore_cycles, base='.agora/store/fragments')
    res = processor.query(q)
    click.echo(jsonify(res.to_dict()))
示例#2
0
def seeds(ctx, query, arg, host, port):
    args = dict(map(lambda a: split_arg(a), arg))
    gw = ctx.obj['gw']

    ted = gw.discover(query, lazy=False)
    dgw = DataGateway(gw.agora, ted, cache=None, port=port, server_name=host)
    seed_uris = dgw.seeds(**args)
    click.echo(jsonify(list(seed_uris)))
示例#3
0
def show_paths(ctx, source, dest):
    gw = ctx.obj['gw']
    try:
        click.echo(jsonify(
            gw.agora.fountain.get_paths(dest,
                                        force_seed=[('<{}-uri>'.format(source.lower()).replace(':', '-'), source)])))
    except TypeError:
        error('Source and/or destination are unknown')
示例#4
0
文件: list.py 项目: fserena/agora-cli
def list_things(ctx):
    ted = ctx.obj['gw'].ted
    thing_ids = map(lambda x: x.id, ted.ecosystem.tds)
    thing_ids.extend(map(lambda x: x.node,
                         ted.ecosystem.non_td_root_resources))
    click.echo(jsonify(thing_ids))
示例#5
0
文件: list.py 项目: fserena/agora-cli
def list_tds(ctx):
    ted = ctx.obj['gw'].ted
    td_ids = map(lambda x: x.id, ted.ecosystem.tds)
    click.echo(jsonify(td_ids))
示例#6
0
文件: list.py 项目: fserena/agora-cli
def list_prefixes(ctx):
    gw = ctx.obj['gw']
    click.echo(jsonify(gw.agora.fountain.prefixes))
示例#7
0
文件: list.py 项目: fserena/agora-cli
def list_types(ctx):
    gw = ctx.obj['gw']
    click.echo(jsonify(gw.agora.fountain.types))
示例#8
0
文件: list.py 项目: fserena/agora-cli
def list_resources(ctx):
    gw = ctx.obj['gw']
    click.echo(jsonify(map(lambda r: r.node, gw.enrichments)))
示例#9
0
文件: list.py 项目: fserena/agora-cli
def list_extensions(ctx):
    gw = ctx.obj['gw']
    click.echo(jsonify(gw.extensions))
示例#10
0
def add_prefix(ctx, prefix, ns):
    gw = ctx.obj['gw']
    gw.agora.fountain.add_prefixes({prefix: ns})
    print jsonify(gw.agora.fountain.prefixes)
示例#11
0
def show_property(ctx, name):
    gw = ctx.obj['gw']
    try:
        click.echo(jsonify(gw.get_property(name)))
    except NotFoundError:
        error('There is no known property called "{}"'.format(name))
示例#12
0
def show_config(ctx):
    click.echo(jsonify(load_config()))
示例#13
0
def show_args(ctx):
    args = ctx.obj['gw'].args
    click.echo(jsonify(args))