def createHive(self): global popenAnswer global popen arrayResponse=self.getArrayResponse() popenAnswer="" popen=None def createthread(): global popen global popenAnswer popen=subprocess.Popen("bii new",shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) popenAnswer=popen.communicate("\n".join(arrayResponse))[0] try: thread=Thread(target=createthread) thread.start() thread.join(timeout=5) if thread.isAlive(): raise Exception("Time out error, please check ") popen.kill() alert("BAD"+str(popenAnswer)) else: alert(str(popenAnswer)) except: error()
import os import subprocess import sys from BasicDialogs import alert if len(sys.argv)<2: alert("Need more arguments") os._exit(1) __author__ = 'Jorge' popen=subprocess.Popen("bii "+sys.argv[1], stdout=subprocess.PIPE) message=popen.communicate()[0] if message!="": alert(message) print "fin"