From e0661a17eb8c3f64651996e8af30f1defcad34cd Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 23 Feb 2012 17:19:06 -0500 Subject: [PATCH] Added command module --- command | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 command diff --git a/command b/command new file mode 100755 index 00000000000..53a8d6ffff1 --- /dev/null +++ b/command @@ -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)