def subprocess(program, cwd, environment, newlines, joined, shell=True, show=False):
"""Create a subprocess using subprocess.Popen."""
stderr = subprocess.STDOUT if joined else subprocess.PIPE
if os.name == 'nt':
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = 0 if show else subprocess.SW_HIDE
cf = subprocess.CREATE_NEW_CONSOLE if show else 0
return subprocess.Popen(program, universal_newlines=newlines, shell=shell, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr, close_fds=False, startupinfo=si, creationflags=cf, cwd=cwd, env=environment)
return subprocess.Popen(program, universal_newlines=newlines, shell=shell, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr, close_fds=True, cwd=cwd, env=environment)
评论列表
文章目录