Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2020 The Magma Authors. |
| 3 | |
| 4 | This source code is licensed under the BSD-style license found in the |
| 5 | LICENSE file in the root directory of this source tree. |
| 6 | |
| 7 | Unless required by applicable law or agreed to in writing, software |
| 8 | distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | See the License for the specific language governing permissions and |
| 11 | limitations under the License. |
| 12 | """ |
| 13 | import os |
| 14 | import sys |
| 15 | |
| 16 | from grpc.tools import protoc |
| 17 | |
| 18 | |
| 19 | def gen_prometheus_proto_py(proto_file_dir, output_dir): |
| 20 | # Function For fb-internal build tools - open source should use this file |
| 21 | # as a script |
| 22 | protoc.main( |
| 23 | ( |
| 24 | '', |
| 25 | '-I' + proto_file_dir, |
| 26 | '--python_out=' + output_dir, |
| 27 | '--grpc_python_out=' + output_dir, |
| 28 | os.path.join(proto_file_dir, 'metrics.proto'), |
| 29 | ), |
| 30 | ) |
| 31 | |
| 32 | |
| 33 | if __name__ == '__main__': |
| 34 | # ./gen_prometheus_proto.py <magma root> <output_dir> |
| 35 | magma_root, out_dir = sys.argv[1], sys.argv[2] |
| 36 | file_dir = os.path.join(magma_root, 'proto_files/orc8r/protos/prometheus') |
| 37 | gen_prometheus_proto_py(file_dir, out_dir) |
| 38 | |