コード例 #1
0
ファイル: codesearch.py プロジェクト: asutherland/mozsearch
def try_info_request(host, port):
    infoq = livegrep_pb2.InfoRequest()

    channel = grpc.insecure_channel('{0}:{1}'.format(host, port))
    grpc_stub = livegrep_pb2_grpc.CodeSearchStub(channel)
    result = grpc_stub.Info(infoq) # maybe add a timeout arg here?
    channel.close()
コード例 #2
0
ファイル: codesearch.py プロジェクト: asutherland/mozsearch
def do_search(host, port, pattern, fold_case, file, context_lines):
    query = livegrep_pb2.Query(line = pattern, file = file, fold_case = fold_case,
                               context_lines = context_lines)
    log('QUERY %s', repr(query).replace('\n', ', '))

    channel = grpc.insecure_channel('{0}:{1}'.format(host, port))
    grpc_stub = livegrep_pb2_grpc.CodeSearchStub(channel)
    result = grpc_stub.Search(query) # maybe add a timeout arg here?
    channel.close()

    matches = collateMatches(result.results)
    log('codesearch result with %d line matches across %d paths', len(result.results), len(matches))
    return (matches, livegrep_pb2.SearchStats.ExitReason.Name(result.stats.exit_reason) == 'TIMEOUT')