|
|
@ -32,18 +32,27 @@ import os
|
|
|
|
|
|
|
|
|
|
|
|
argfile = sys.argv[1]
|
|
|
|
argfile = sys.argv[1]
|
|
|
|
args = open(argfile, 'r').read()
|
|
|
|
args = open(argfile, 'r').read()
|
|
|
|
args = shlex.split(args)
|
|
|
|
|
|
|
|
|
|
|
|
shell = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.find("#USE_SHELL") != -1:
|
|
|
|
|
|
|
|
args = args.replace("#USE_SHELL", "")
|
|
|
|
|
|
|
|
shell = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not shell:
|
|
|
|
|
|
|
|
args = shlex.split(args)
|
|
|
|
|
|
|
|
|
|
|
|
startd = datetime.datetime.now()
|
|
|
|
startd = datetime.datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cmd = subprocess.Popen(args, shell=False,
|
|
|
|
cmd = subprocess.Popen(args, shell=shell,
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
out, err = cmd.communicate()
|
|
|
|
out, err = cmd.communicate()
|
|
|
|
except (OSError, IOError), e:
|
|
|
|
except (OSError, IOError), e:
|
|
|
|
print json.dumps({
|
|
|
|
print json.dumps({
|
|
|
|
"failed": 1,
|
|
|
|
"cmd" : args,
|
|
|
|
"msg": str(e),
|
|
|
|
"failed" : 1,
|
|
|
|
|
|
|
|
"msg" : str(e),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
@ -62,6 +71,7 @@ if err is None:
|
|
|
|
err = ''
|
|
|
|
err = ''
|
|
|
|
|
|
|
|
|
|
|
|
result = {
|
|
|
|
result = {
|
|
|
|
|
|
|
|
"cmd" : args,
|
|
|
|
"stdout" : out.strip(),
|
|
|
|
"stdout" : out.strip(),
|
|
|
|
"stderr" : err.strip(),
|
|
|
|
"stderr" : err.strip(),
|
|
|
|
"rc" : cmd.returncode,
|
|
|
|
"rc" : cmd.returncode,
|
|
|
|