Added command module
This commit is contained in:
parent
d27b55baa4
commit
e0661a17eb
1 changed files with 27 additions and 0 deletions
27
command
Executable file
27
command
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
args = sys.argv[1:]
|
||||
startd = datetime.datetime.now()
|
||||
|
||||
cmd = subprocess.Popen(args, shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
out, err = cmd.communicate()
|
||||
endd = datetime.datetime.now()
|
||||
delta = endd - startd
|
||||
|
||||
result = {
|
||||
"stdout" : out,
|
||||
"stderr" : err,
|
||||
"rc" : cmd.returncode,
|
||||
"start" : str(startd),
|
||||
"end" : str(endd),
|
||||
"delta" : str(delta),
|
||||
}
|
||||
|
||||
print json.dumps(result)
|
Loading…
Reference in a new issue