[wingide-users] Using subprocess in scripts
Michael Foord
fuzzyman at voidspace.org.uk
Sat Dec 30 17:41:17 MST 2006
Michael Foord wrote:
> Hello all,
>
> I'm experimenting with writing scripts.
>
> The problem with using 'os.system' to launch scripts is that it is
> synchronous - WingIDE is blocked until the script returns.
>
> I would like to use 'subprocess' to launch commands. The 'subprocess'
> module isn't included in the Wing 'Python24.zip', so I can't use it. Any
> reason why it isn't available ?
>
FWIW this is my solution :
import wingapi
import os
from threading import Thread
def custom_execute(app=wingapi.kArgApplication):
editor = app.GetActiveEditor()
filename = editor.GetDocument().GetFilename()
directory, theFile = os.path.split(filename)
if os.path.split(directory)[1] == 'UnitTests':
directory = os.path.split(directory)[0]
os.chdir(directory)
thread = Thread(target=lambda: os.system('run_python "%s"' % filename))
thread.start()
> All the best,
>
>
> Michael Foord
> http://www.voidspace.org.uk/python/articles.shtml
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>
>
More information about the wingide-users
mailing list