I use wxpython
for GUI and bash for script. I have to run a .exe
file from a Python script using subprocess.
Purpose: Must pass parameter from GUI to the .exe
file, and don't have permission to check it.
Part of my code where I am getting the problem is:
import subprocess
def OnBound(self,event):
lan1 = self.sc1.Getvalue() ##interger value
arg = ('home/proj/lic.exe')
subprocess.call([lan1, arg], shell = True)
Whenever I run my script I get the following error:
Traceback (most recent call last)
File "/usr/lib/python 2.7/subprocess.py", line 493, in call return popen(*popnargs, **kwargs).wait()
File "/usr/lib/python 2.7/subprocess.py", line 679, in __init__errread,errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1239, in _execute_child raise child_exception
Type error: execv() arg 2 must contain only strings
What may I have done wrong here? Any help / suggestions would be helpful as I am new to python.
All items in the first parameter of subprocess.call
must be strings:
rc = subprocess.call(['/home/proj/lic.exe', str(lan1)])
Also you shouldn't call functions that can block for a long time from a GUI event handler; it can freeze your GUI for a long time. You could call subprocess.Popen
to return immediately instead and schedule an idle callback to poll the subprocess state periodically.