2013-04-29 60 views
2

我設計使用pythonqt的接口,當我嘗試使用os.system,接口凍結打電話給我的程序。Python的OS故障

def pairClicked(self,exp1,exp2): 
     os.system("""cd kat 
        ./run -v pair""") #in the terminal i used to call my python interface, it runs this commands 
     os.system(exp1+" "+expr2) #but here nothing happens 

一旦我殺程序的終端說,(在exp1=t1exp2=t2情況下):

sh 1: t1 not found 
sh 2: t2 not found 

任何IDEIA /什麼IAM做錯了建議嗎? 請注意,這是我第一次做這類事情。

編輯:

我已經編輯和使用這段代碼,而不是

p=subprocess.Popen(['cd','kat','./run', '-pair', str(test.__len__()),expr1Text,expr2Text],stdout=subprocess.PIPE,shell=True) 
out= p.communicate() 
print(out) 

但它返回('',None)。 我認爲這個問題是我使用的命令一樣cd kat ./run -pair *len* expr1 expr2代替:

如何使用子進程作出新的生產線?

+0

'run'是什麼? – Blender 2013-04-29 02:25:36

回答

1

這聽起來像./run阻止。

您可能需要產生一個異步子進程或可能使用另一個線程,因此您的GUI可以在./run運行時繼續工作。