-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (19 loc) · 977 Bytes
/
Copy pathmain.py
File metadata and controls
23 lines (19 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def compile_protobuf():
print("Compiling protos...")
import os
os.system("python -m grpc_tools.protoc -I networking/rpc_misc/proto --python_out=networking/rpc_misc "
"--grpc_python_out=networking/rpc_misc networking/rpc_misc/proto/client_server_interface.proto")
modified_file = ""
file_path = os.path.join("networking","rpc_misc","client_server_interface_pb2_grpc.py")
with open(file_path, 'r') as f:
for line in f:
if "import client_server_interface_pb2" in line:
modified_file = "{}{}".format(modified_file, "from . import client_server_interface_pb2 as "
"client__server__interface__pb2")
else:
modified_file = "{}{}".format(modified_file, line)
with open(file_path, 'w') as f:
f.write(modified_file)
print("Protos compiled successfully!")
if __name__ == "__main__":
compile_protobuf()