-
Notifications
You must be signed in to change notification settings - Fork 0
/
bp.py
64 lines (46 loc) · 1.12 KB
/
bp.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
# coding=utf-8
import sys
from typing import Tuple
from script.util.Printer import Printer
from script.EasyCoding import EasyCoding
def on_launch(argv: list):
ec = EasyCoding()
ec.shell(argv)
def exec_cmd(cmd: str) -> int:
# exec
sys.stdout.write('cmd:%s\n' % cmd)
sys.stdout.flush()
# get cmd exit code
str_code = sys.stdin.readline().strip()
try:
code = int(str_code)
except ValueError:
code = 1
return code
def exec_func(cmd: str) -> Tuple[int, str]:
# exec
sys.stdout.write('func:%s\n' % cmd)
sys.stdout.flush()
# get cmd exit code
str_code = sys.stdin.readline().strip()
try:
code = int(str_code)
except ValueError:
code = 1
# receive cmd output
outputs = []
line = sys.stdin.readline().strip()
while line != '==end==':
outputs.append(line)
line = sys.stdin.readline().strip()
output = '\n'.join(outputs)
# return
return code, output
def launch():
# parser args
on_launch(sys.argv)
# end
print('==end==')
if __name__ == "__main__":
launch()