

def _popen(self, executable, argv, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=None, env=None, new_session=False, **kwargs):
    if new_session:
        if has_new_subprocess:
            kwargs['start_new_session'] = True
        elif IS_WIN32:
            kwargs['creationflags'] = (kwargs.get('creationflags', 0) | subprocess.CREATE_NEW_PROCESS_GROUP)
        else:

            def preexec_fn(prev_fn=kwargs.get('preexec_fn', (lambda : None))):
                os.setsid()
                prev_fn()
            kwargs['preexec_fn'] = preexec_fn
    if (IS_WIN32 and ('startupinfo' not in kwargs) and (stdin not in (sys.stdin, None))):
        from plumbum.machines._windows import get_pe_subsystem, IMAGE_SUBSYSTEM_WINDOWS_CUI
        subsystem = get_pe_subsystem(str(executable))
        if (subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI):
            sui = subprocess.STARTUPINFO()
            kwargs['startupinfo'] = sui
            if hasattr(subprocess, '_subprocess'):
                sui.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
                sui.wShowWindow = subprocess._subprocess.SW_HIDE
            else:
                sui.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                sui.wShowWindow = subprocess.SW_HIDE
    if ((not has_new_subprocess) and ('close_fds' not in kwargs)):
        if (IS_WIN32 and ((stdin is not None) or (stdout is not None) or (stderr is not None))):
            kwargs['close_fds'] = False
        else:
            kwargs['close_fds'] = True
    if (cwd is None):
        cwd = self.cwd
    if (env is None):
        env = subsystem.env
    if isinstance(env, BaseEnv):
        env = env.getdict()
    if self._as_user_stack:
        (argv, executable) = self._as_user_stack[(- 1)](argv)
    logger.debug('Running %r', argv)
    proc = IterablePopen(argv, executable=str(executable), stdin=stdin, stdout=stdout, stderr=stderr, cwd=str(cwd), env=env, **kwargs)
    proc._start_time = time.time()
    proc.encoding = self.encoding
    proc.argv = argv
    return proc

dataset/ETHPy150Open tomerfiliba/plumbum/plumbum/machines/local.py LocalMachine._popen/VarMisuse@352/508 `self`->`subsystem`