Artur Peniche
Artur Peniche

Reputation: 479

Python OS malfunction

I am designing an interface using pythonqt, and when I try to call my program using os.system, the interface freezes.

 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

Once i kill the program the terminal says (in case of exp1=t1 and exp2=t2):

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

Any ideia/sugestions of what iam doing wrong? Take note that this is the first time I am doing anything of this kind.

Edit:

I've edited and used this piece of code instead

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

But it's returning ('',None). I think the problem is I am using the command like cd kat ./run -pair *len* expr1 expr2 instead of:

cd kat
./run -pair *len*
expr1
expr2

How can I use subprocess to make new lines?

Upvotes: 2

Views: 185

Answers (1)

dstromberg
dstromberg

Reputation: 7167

It sounds like ./run is blocking.

You'll probably need to spawn an asynchronous subprocess or perhaps use another thread, so your GUI can continue working while ./run is running.

Upvotes: 1

Related Questions