Commit 6f8d090a authored by Michael Büsch's avatar Michael Büsch

subprocess: Add option to avoid creating a new window

This suppresses the coreserver console window on Windows.
Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 3c0394d2
......@@ -42,18 +42,25 @@ def findExecutable(executable):
return distutils.spawn.find_executable(executable)
class PopenWrapper(object):
def __init__(self, argv, env, stdio = False):
def __init__(self, argv, env, stdio=False, hideWindow=False):
if isIronPython:
self.__pid = os.spawnve(os.P_NOWAIT,
argv[0], argv, dict(env))
else:
if osIsWindows and hideWindow:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
else:
startupinfo = None
self.__proc = subprocess.Popen(
argv,
env = dict(env),
shell = False,
stdin = subprocess.PIPE if stdio else None,
stdout = subprocess.PIPE if stdio else None,
stderr = subprocess.PIPE if stdio else None
env=dict(env),
shell=False,
stdin=subprocess.PIPE if stdio else None,
stdout=subprocess.PIPE if stdio else None,
stderr=subprocess.PIPE if stdio else None,
startupinfo=startupinfo
)
def terminate(self):
......
......@@ -177,7 +177,8 @@ class AwlSimServer(object): #+cdef
forkServerProcess)
try:
serverProcess = PopenWrapper([proc],
env = env)
env=env,
hideWindow=True)
except OSError as e:
raise AwlSimError("Failed to run executable '%s': %s" %(
forkServerProcess, str(e)))
......@@ -192,7 +193,8 @@ class AwlSimServer(object): #+cdef
try:
serverProcess = PopenWrapper(
[interp, "-m", "awlsim.coreserver.run"],
env = env)
env=env,
hideWindow=True)
except OSError as e:
raise AwlSimError("Failed to run interpreter '%s': %s" %(
forkInterpreter, str(e)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment