-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbp.sh
More file actions
98 lines (76 loc) · 1.81 KB
/
bp.sh
File metadata and controls
98 lines (76 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
PYTHON_SCRIPT=${EC_DIR}/bp.py
CTRL_C_DETECTED=FALSE
source ${BASH_DIR}/util.sh
source ${BASH_DIR}/env.sh
#source bash/util.sh
#source bash/env.sh
function execScript() {
# begin conda
condaBegin
if [ $? != 0 ]; then
print ${COLOR_RED} "Conda not installed, please install first."
return $?
fi
# enter python 2 for AOSP make
enterPython2
#################################
# begin script
# init pipe
initPipeIn_6
initPipeOut_7
# start script
({
enterPython3
${PYTHON_BIN} ${PYTHON_SCRIPT} $@ >&6 <&7
leavePython3
} &)
# read and exec
while [[ TRUE ]]; do
# read command from python script
read -u6 line
# check command end
if [[ ${line} == "==end==" ]]; then
break
fi
# check Ctrl+C
if [[ ${CTRL_C_DETECTED} == TRUE ]]; then
print ${COLOR_GREEN} "=====> cancel by [Ctrl+C]"
break
fi
# run command
if [[ ${line} == "cmd:"* ]]; then
# run command
eval ${line#cmd:}
# feedback exit code
echo "$?" >&7
elif [[ ${line} == "func:"* ]]; then
# run command & get output
result=$(eval ${line#func:})
# feedback output
echo "$?" >&7
echo ${result} >&7
echo "==end==" >&7
else
# echo message
echo -e "${line}"
fi
done
# release pipe
releasePipeIn_6
releasePipeOut_7
# end script
###############################
# leave python 2
leavePython2
# end conda
condaEnd
return 0
}
########################
# entry
function onCtrlC () {
CTRL_C_DETECTED=TRUE
}
trap "onCtrlC" INT
execScript $@