Exemple #1
0
  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
Exemple #3
0
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))
Exemple #4
0
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
Exemple #6
0
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',
    )
)
Exemple #8
0
from grpc.tools import protoc

protoc.main(("", "-I.", "--python_out=.", "--grpc_python_out=.",
             "./tokenization.proto"))
Exemple #9
0
#!/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',
))
Exemple #11
0
from grpc.tools import protoc

protoc.main(('', '-I.', '--python_out=../api', '--grpc_python_out=../api',
             './PointCloud.proto'))
Exemple #12
0
from grpc.tools import protoc

protoc.main(
(
        '',
        '-I.',
        '--python_out=../bindings/python',
        '--grpc_python_out=../bindings/python',
        'coprocess_object.proto',
)
)
Exemple #13
0
# 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',
    )
)
Exemple #14
0
# 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',
    )
)
Exemple #15
0
"""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',
))
Exemple #16
0
from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './grpc_todo.proto',
))
Exemple #17
0
from grpc.tools import protoc

protoc.main(
    (
        '',
        '-I.',
        '--python_out=.',
        '--grpc_python_out=.',
        './filesendtest.proto',
    )
)
Exemple #18
0
# -*- coding: utf-8 -*-

from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './echo_server.proto',
))
Exemple #19
0
from grpc.tools import protoc

protoc.main(
    (
        '',
        '-I.',
        '--python_out=.',
        '--grpc_python_out=.',
        './proto/simple.proto',
    )
)
Exemple #20
0
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),
        )
    )
Exemple #22
0
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',
))
Exemple #24
0
from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './xarm_shuidi.proto',
))
Exemple #25
0
from grpc.tools import protoc

protoc.main(
    (
        "" , 
        "-I./" , 
        "--python_out=./" , 
        "--grpc_python_out=./" , 
        "./service.proto" , 
    )
)
Exemple #26
0
from grpc.tools import protoc

protoc.main(
    (
      '',
      '--proto_path=.',
      '--python_out=.',
      '--grpc_python_out=.',
      './solver.proto'
    )
)
Exemple #27
0
"""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),
))
Exemple #28
0
from grpc.tools import protoc

protoc.main(
    (
        '',
        '-I.',
        '--python_out=.',
        '--grpc_python_out=.',
        'cvimg.proto',
    )
)
Exemple #29
0
from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './my_if.proto',
))
Exemple #30
0
from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './node.proto',
))
Exemple #31
0
# 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',
    )
)
Exemple #32
0
# 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',
))
Exemple #33
0
from grpc.tools import protoc

protoc.main({
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './msg.proto',
})
Exemple #34
0
#     * 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',
))
Exemple #35
0
from grpc.tools import protoc

protoc.main(('', '--proto_path=../../proto/', '--python_out=.',
             '--grpc_python_out=.', '../../proto/vuelos.proto'))
Exemple #36
0
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,
Exemple #37
0
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',
))
Exemple #40
0
# -*- coding: utf-8 -*-

from grpc.tools import protoc

protoc.main(
    (
        '',
        '-I.',
        '--python_out=.',
        '--grpc_python_out=.',
        './echo_server.proto',
    )
)
Exemple #41
0
from grpc.tools import protoc

protoc.main((
    '',
    '-I.',
    '--python_out=.',
    '--grpc_python_out=.',
    './egoisticlily.proto',
))