+ #print "calling select(%s)" % timeout
+ lout, lin, lerr = select([f_out], [], [f_err], timeout)
+ #print "TIMEOUT!!!!!!!!!!!!!!!!!!!"
+ if len(lin) == 0 and len(lout) == 0 and len(lerr) == 0:
+ # Reached a timeout! Nuke process so it does not hang.
+ #print "KILLING"
+ s.kill(signal.SIGKILL)
+ raise ExceptionTimeout("TIMEOUT Running: %s" % cmd)
+ else:
+ #print "RETURNING"
+ #print len(lin), len(lout), len(lerr)
+ pass
+
+ o_value = ""
+ e_value = ""
+
+ #print "reading from f_out"
+ if len(lout) > 0: o_value = f_out.read()
+ #print "reading from f_err"
+ if len(lerr) > 0: e_value = f_err.read()
+
+ #print "striping output"
+ o_value = o_value.strip()
+ e_value = e_value.strip()
+
+ #print "OUTPUT", o_value, e_value
+
+ #print "closing files"
+ f_out.close()
+ f_in.close()
+ f_err.close()
+ try:
+ #print "s.kill()"
+ s.kill()
+ #print "after s.kill()"
+ except OSError:
+ # no such process, due to it already exiting...
+ pass
+
+ #print o_value, e_value
+ return (o_value, e_value)
+
+ def runargs(self, args, timeout=COMMAND_TIMEOUT*2):
+
+ #print "CMD.run(%s)" % " ".join(args)
+ s = Sopen(args, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+ self.s = s
+ (f_in, f_out, f_err) = (s.stdin, s.stdout, s.stderr)
+ lout, lin, lerr = select([f_out], [], [f_err], timeout)