Example #1
0
def compile_proto(entry_path, codegen_dir, proto_file=None):
    try:
        if not os.path.exists(str(codegen_dir)):
            os.makedirs(str(codegen_dir))
        proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')

        compiler_args = [
            "-I{}".format(entry_path), "-I{}".format(proto_include)
        ]

        compiler_args.insert(0, "protoc")
        compiler_args.append("--python_out={}".format(codegen_dir))
        compiler_args.append("--grpc_python_out={}".format(codegen_dir))

        if proto_file:
            compiler_args.append(str(proto_file))
        else:
            compiler_args.extend(
                [str(p) for p in entry_path.glob("**/*.proto")])

        if not protoc(compiler_args):
            return True
        else:
            return False
    except Exception as e:
        print("{}\n{}".format(e, traceback.print_exc()))
        return False
Example #2
0
def compile_proto(entry_path, codegen_dir, proto_file=None):
    try:
        if not os.path.exists(codegen_dir):
            os.makedirs(codegen_dir)
        proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
        protoc_args = [
            "protoc", "-I{}".format(entry_path), '-I{}'.format(proto_include),
            "--python_out={}".format(codegen_dir),
            "--grpc_python_out={}".format(codegen_dir)
        ]
        if proto_file:
            protoc_args.append(str(proto_file))
        else:
            protoc_args.extend([str(p) for p in entry_path.glob("**/*.proto")])

        if not protoc(protoc_args):
            return True
        else:
            return False

    except Exception as e:
        return False
Example #3
0
def compile_proto(entry_path, codegen_dir, proto_file=None):
    try:
        if not os.path.exists(codegen_dir):
            os.makedirs(codegen_dir)
        proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
        protoc_args = [
            "protoc",
            "-I{}".format(entry_path),
            '-I{}'.format(proto_include),
            "--python_out={}".format(codegen_dir),
            "--grpc_python_out={}".format(codegen_dir)
        ]
        if proto_file:
            protoc_args.append(str(proto_file))
        else:
            protoc_args.extend([str(p) for p in entry_path.glob("**/*.proto")])

        if not protoc(protoc_args):
            return True
        else:
            return False

    except Exception as e:
        return False