If I save my code files as .pyw, no console window appears - which is what I want - but if the code includes a call to os.system, I still get a pes
People are a bit lazy... I would thx @Piotr Dobrogost and @Frank S. Thomas for their answers.
I came with this code who is runinng on Linux and Windows:
import platform
import subprocess
startupinfo = None
if platform.system() == 'Windows':
import _subprocess # @bug with python 2.7 ?
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = _subprocess.SW_HIDE
Later...
args = [exe, ...]
out = subprocess.check_output(args, startupinfo=startupinfo)
Thx guys ;)
Additionally: just to note that the following code using 'call' also works on Python 2.7 (on Windows) with the 'startupinfo' code above:
def run_command(cmd, sin, sout):
print "Running cmd : %s"%(" ".join(cmd) )
return subprocess.call( cmd, stdin=sin, stdout=sout, startupinfo=startupinfo)