forked from davidkonge/v2ray_python_client
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauto_gen_proto.py
More file actions
43 lines (37 loc) · 1.01 KB
/
auto_gen_proto.py
File metadata and controls
43 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import os
import shutil
import grpc_tools.protoc as proto
import pathlib
import sys
def fixDir():
if not pathlib.Path("v2ray.com/core").exists():
try:
os.mkdir("v2ray.com")
except FileExistsError as e:
print(e)
except PermissionError as e:
print(e)
for (path, _, fileName) in os.walk('.'):
for i in fileName:
if i.endswith(".proto"):
return path
def genProto():
for (path, _, fileName) in os.walk("./"):
for i in fileName:
if i.endswith(".proto"):
p = path+"/"+i
proto.main("--proto_path=./ --python_out=./ --grpc_python_out=./ {}".format(p).split())
path = fixDir()
if not pathlib.Path("core").exists():
try:
os.renames(path, "core")
except PermissionError as e:
print(e)
sys.exit()
try:
shutil.move('core', 'v2ray.com/core')
except PermissionError as e:
print(e)
sys.exit()
genProto()