+
+ def system(self, cmd, timeout=COMMAND_TIMEOUT*2):
+ (o,e) = self.run(cmd, timeout)
+ self.output = o
+ self.error = e
+ if self.s.returncode is None:
+ self.s.wait()
+ return self.s.returncode
+
+ def run(self, cmd, timeout=COMMAND_TIMEOUT*2):
+
+ #print "CMD.run(%s)" % cmd
+ s = Sopen(cmd, 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)
+ #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 = ""