-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_line.py
35 lines (34 loc) · 1.14 KB
/
command_line.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
import os
import sys
import shlex
import logging
import traceback
from buildster import buildster as build
def main():
environment = os.environ.copy()
arguments = sys.argv
command = []
environment["BUILDSTER_WD"] = os.getcwd()
if (len(arguments) > 1):
arguments = arguments[1:]
for i in range(len(arguments)):
argument = arguments[i]
arguments[i] = "arguments.append(\""+shlex.quote(argument)+"\")"
if (len(arguments) > 1):
arguments = "; ".join(arguments)
else:
arguments = arguments[0]
command.append(sys.executable)
command.append("-c")
command.append("import sys; from buildster import buildster as build; arguments = []; "+arguments+"; sys.argv += arguments; print(str(sys.argv)); build.main()")
print(str(command))
result = ""
try:
result = build.execute_command(command, environment)
except Exception as exception:
result = ""
logging.error(traceback.format_exc())
#print(result.strip())
else:
print(str(build.main(environment)))
return 0