def run(self): import grpc.tools.protoc as protoc include_regex = re.compile(self.include) exclude_regex = re.compile(self.exclude) if self.exclude else None paths = [] for walk_root, directories, filenames in os.walk(PROTO_STEM): for filename in filenames: path = os.path.join(walk_root, filename) if include_regex.match(path) and not ( exclude_regex and exclude_regex.match(path)): paths.append(path) # TODO(kpayson): It would be nice to do this in a batch command, # but we currently have name conflicts in src/proto for path in paths: command = [ 'grpc.tools.protoc', '-I {}'.format(PROTO_STEM), '--python_out={}'.format(PROTO_STEM), '--grpc_python_out={}'.format(PROTO_STEM), ] + [path] if protoc.main(command) != 0: sys.stderr.write( 'warning: Command:\n{}\nFailed'.format( command)) # Generated proto directories dont include __init__.py, but # these are needed for python package resolution for walk_root, _, _ in os.walk(PROTO_STEM): path = os.path.join(walk_root, '__init__.py') open(path, 'a').close()
def setUp(self): same_proto_contents = pkgutil.get_data( 'tests.protoc_plugin.protos.invocation_testing', 'same.proto') self.directory = tempfile.mkdtemp(suffix='same_separate', dir='.') self.proto_directory = os.path.join(self.directory, 'proto_path') self.python_out_directory = os.path.join(self.directory, 'python_out') self.grpc_python_out_directory = os.path.join(self.directory, 'grpc_python_out') os.makedirs(self.proto_directory) os.makedirs(self.python_out_directory) os.makedirs(self.grpc_python_out_directory) same_proto_file = os.path.join(self.proto_directory, 'same_separate.proto') open(same_proto_file, 'wb').write(same_proto_contents) protoc_result = protoc.main([ '', '--proto_path={}'.format(self.proto_directory), '--python_out={}'.format(self.python_out_directory), '--grpc_python_out={}'.format(self.grpc_python_out_directory), same_proto_file, ]) if protoc_result != 0: raise Exception("unexpected protoc error") open(os.path.join(self.grpc_python_out_directory, '__init__.py'), 'w').write('') open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') self.pb2_import = 'same_separate_pb2' self.pb2_grpc_import = 'same_separate_pb2_grpc' self.should_find_services_in_pb2 = False
def build_package_protos(package_root): proto_files = [] inclusion_root = os.path.abspath(package_root) for root, _, files in os.walk(inclusion_root): for filename in files: if filename.endswith('.proto'): proto_files.append(os.path.abspath(os.path.join(root, filename))) for proto_file in proto_files: command = [ 'grpc.tools.protoc', '--proto_path={}'.format(inclusion_root), '--python_out={}'.format(inclusion_root), '--grpc_python_out={}'.format(inclusion_root), ] + [proto_file] if protoc.main(command) != 0: sys.stderr.write('warning: {} failed'.format(command))
def build_package_protos(package_root): proto_files = [] inclusion_root = os.path.abspath(package_root) for root, _, files in os.walk(inclusion_root): for filename in files: if filename.endswith(".proto"): proto_files.append(os.path.abspath(os.path.join(root, filename))) well_known_protos_include = pkg_resources.resource_filename("grpc.tools", "_proto") for proto_file in proto_files: command = [ "grpc.tools.protoc", "--proto_path={}".format(inclusion_root), "--proto_path={}".format(well_known_protos_include), "--python_out={}".format(inclusion_root), "--grpc_python_out={}".format(inclusion_root), ] + [proto_file] if protoc.main(command) != 0: sys.stderr.write("warning: {} failed".format(command))
def setUp(self): services_proto_contents = pkgutil.get_data( 'tests.protoc_plugin.protos.invocation_testing.split_services', 'services.proto') messages_proto_contents = pkgutil.get_data( 'tests.protoc_plugin.protos.invocation_testing.split_messages', 'messages.proto') self.directory = tempfile.mkdtemp(suffix='split_common', dir='.') self.proto_directory = os.path.join(self.directory, 'proto_path') self.python_out_directory = os.path.join(self.directory, 'python_out') self.grpc_python_out_directory = self.python_out_directory os.makedirs(self.proto_directory) os.makedirs(self.python_out_directory) services_proto_file = os.path.join(self.proto_directory, 'split_common_services.proto') messages_proto_file = os.path.join(self.proto_directory, 'split_common_messages.proto') open(services_proto_file, 'wb').write(services_proto_contents.replace( _MESSAGES_IMPORT, b'import "split_common_messages.proto";' )) open(messages_proto_file, 'wb').write(messages_proto_contents) protoc_result = protoc.main([ '', '--proto_path={}'.format(self.proto_directory), '--python_out={}'.format(self.python_out_directory), '--grpc_python_out={}'.format(self.python_out_directory), services_proto_file, messages_proto_file, ]) if protoc_result != 0: raise Exception("unexpected protoc error") open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') self.pb2_import = 'split_common_messages_pb2' self.pb2_grpc_import = 'split_common_services_pb2_grpc' self.should_find_services_in_pb2 = False
from grpc.tools import protoc protoc.main( ('', '-I.', '--python_out=.', '--grpc_python_out=.', './Datas.proto'))
from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=../lib/', '--grpc_python_out=../lib/', './detection.proto', ) )
from grpc.tools import protoc protoc.main(("", "-I.", "--python_out=.", "--grpc_python_out=.", "./tokenization.proto"))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 4 13:05:39 2020 @author: Anirban Das """ from grpc.tools import protoc import sys if len(sys.argv) > 1: protofile = sys.argv[1] else: protofile = "./node.proto" protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', protofile, ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=./server/python', '--grpc_python_out=./server/python', './proto/helloworld.proto', ))
from grpc.tools import protoc protoc.main(('', '-I.', '--python_out=../api', '--grpc_python_out=../api', './PointCloud.proto'))
from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=../bindings/python', '--grpc_python_out=../bindings/python', 'coprocess_object.proto', ) )
# distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main( ( '', '-I../../protos', '--python_out=.', '--grpc_python_out=.', '../../protos/route_guide.proto', ) )
# distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=.', '--grpc_python_out=.', './lcmbridge.proto', ) )
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main(( '', '-I./', '--python_out=.', '--grpc_python_out=.', './experiment.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './grpc_todo.proto', ))
from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=.', '--grpc_python_out=.', './filesendtest.proto', ) )
# -*- coding: utf-8 -*- from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './echo_server.proto', ))
from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=.', '--grpc_python_out=.', './proto/simple.proto', ) )
from grpc.tools import protoc protoc.main( ( '', '-I../../libmumbot/proto', '--python_out=.', '--grpc_python_out=.', '../../libmumbot/proto/MumBot.proto', ) )
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc files = [ 'users', 'settings', 'files', 'entities', 'bookings', 'items', 'schedules' ] for file in files: protoc.main( ( '', '-Iprotos', '--python_out=./generated', '--grpc_python_out=./generated', 'protos/{}.proto'.format(file), ) )
from grpc.tools import protoc protoc.main(( '', '--python_out=.', '--grpc_python_out=.', 'greeter.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './proto/position.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './xarm_shuidi.proto', ))
from grpc.tools import protoc protoc.main( ( "" , "-I./" , "--python_out=./" , "--grpc_python_out=./" , "./service.proto" , ) )
from grpc.tools import protoc protoc.main( ( '', '--proto_path=.', '--python_out=.', '--grpc_python_out=.', './solver.proto' ) )
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc import logging import os import sys snap_proto = os.environ.get("SNAP_PROTO") if snap_proto == None: logging.error("Environment variable `SNAP_PROTO` must be set") sys.exit(1) protoc.main(( '', '-I{}/'.format(snap_proto), '--python_out=../snap_plugin/v1/', '--grpc_python_out=../snap_plugin/v1/', '{}/plugin.proto'.format(snap_proto), ))
from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=.', '--grpc_python_out=.', 'cvimg.proto', ) )
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './my_if.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './node.proto', ))
# distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main( ( '', '-I../../protos', '--python_out=.', '--grpc_python_out=.', '../../protos/helloworld.proto', ) )
# notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main(( '', '--python_out=.', '--grpc_python_out=.', '../sms.proto', ))
from grpc.tools import protoc protoc.main({ '', '-I.', '--python_out=.', '--grpc_python_out=.', './msg.proto', })
# * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" from grpc.tools import protoc protoc.main(( '', '-I./', '--python_out=.', '--grpc_python_out=.', './jobupload.proto', ))
from grpc.tools import protoc protoc.main(('', '--proto_path=../../proto/', '--python_out=.', '--grpc_python_out=.', '../../proto/vuelos.proto'))
tensor_proto = os.path.join(tensorflow_root, tensorflow_core_framework, 'tensor.proto') resource_handle_proto = os.path.join(tensorflow_root, tensorflow_core_framework, 'resource_handle.proto') tensor_shape_proto = os.path.join(tensorflow_root, tensorflow_core_framework, 'tensor_shape.proto') types_proto = os.path.join(tensorflow_root, tensorflow_core_framework, 'types.proto') protoc.main(( '', '-I%s' % (tensorflow_serving_root), '-I%s' % (os.path.join(tensorflow_serving_root, 'tensorflow')), '-I%s' % (distproto), '--python_out=%s' % (tmpdir), '--grpc_python_out=%s' % (tmpdir), model_proto, predict_proto, prediction_service, )) protoc.main(( '', '-I%s' % (tensorflow_root), '-I%s' % (distproto), '--python_out=%s' % (tmpdir), '--grpc_python_out=%s' % (tmpdir), tensor_proto, resource_handle_proto, tensor_shape_proto,
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=../bindings/python', '--grpc_python_out=../bindings/python', 'coprocess_object.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './hello.proto', ))
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './protobuf/roll_out_service.proto', ))
# -*- coding: utf-8 -*- from grpc.tools import protoc protoc.main( ( '', '-I.', '--python_out=.', '--grpc_python_out=.', './echo_server.proto', ) )
from grpc.tools import protoc protoc.main(( '', '-I.', '--python_out=.', '--grpc_python_out=.', './egoisticlily.proto', ))