Wei-Yu Chen | ad55cb8 | 2022-02-15 20:07:01 +0800 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2020 The Magma Authors. |
| 2 | # SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org> |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 5 | |
Wei-Yu Chen | 49950b9 | 2021-11-08 19:19:18 +0800 | [diff] [blame] | 6 | import os |
| 7 | import sys |
| 8 | |
| 9 | from grpc.tools import protoc |
| 10 | |
| 11 | |
| 12 | def gen_prometheus_proto_py(proto_file_dir, output_dir): |
| 13 | # Function For fb-internal build tools - open source should use this file |
| 14 | # as a script |
| 15 | protoc.main( |
| 16 | ( |
| 17 | '', |
| 18 | '-I' + proto_file_dir, |
| 19 | '--python_out=' + output_dir, |
| 20 | '--grpc_python_out=' + output_dir, |
| 21 | os.path.join(proto_file_dir, 'metrics.proto'), |
| 22 | ), |
| 23 | ) |
| 24 | |
| 25 | |
| 26 | if __name__ == '__main__': |
| 27 | # ./gen_prometheus_proto.py <magma root> <output_dir> |
| 28 | magma_root, out_dir = sys.argv[1], sys.argv[2] |
| 29 | file_dir = os.path.join(magma_root, 'proto_files/orc8r/protos/prometheus') |
| 30 | gen_prometheus_proto_py(file_dir, out_dir) |
| 31 | |