本文整理汇总了Python中subprocess.Popen.argv方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.argv方法的具体用法?Python Popen.argv怎么用?Python Popen.argv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.argv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _popen
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import argv [as 别名]
def _popen(self, executable, argv, stdin = PIPE, stdout = PIPE, stderr = PIPE,
cwd = None, env = None, **kwargs):
if subprocess.mswindows and "startupinfo" not in kwargs and stdin not in (sys.stdin, None):
kwargs["startupinfo"] = sui = subprocess.STARTUPINFO()
if hasattr(subprocess, "_subprocess"):
sui.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW # @UndefinedVariable
sui.wShowWindow = subprocess._subprocess.SW_HIDE # @UndefinedVariable
else:
sui.dwFlags |= subprocess.STARTF_USESHOWWINDOW # @UndefinedVariable
sui.wShowWindow = subprocess.SW_HIDE # @UndefinedVariable
if cwd is None:
cwd = self.cwd
if env is None:
env = self.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 = Popen(argv, executable = str(executable), stdin = stdin, stdout = stdout,
stderr = stderr, cwd = str(cwd), env = env, **kwargs) # bufsize = 4096
proc._start_time = time.time()
proc.encoding = self.encoding
proc.argv = argv
return proc
示例2: popen
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import argv [as 别名]
def popen(self, args = (), stdin = PIPE, stdout = PIPE, stderr = PIPE, cwd = None,
env = None, **kwargs):
if isinstance(args, str):
args = (args,)
if subprocess.mswindows and "startupinfo" not in kwargs and stdin not in (sys.stdin, None):
kwargs["startupinfo"] = subprocess.STARTUPINFO()
kwargs["startupinfo"].dwFlags |= subprocess.STARTF_USESHOWWINDOW #@UndefinedVariable
kwargs["startupinfo"].wShowWindow = subprocess.SW_HIDE #@UndefinedVariable
if cwd is None:
cwd = getattr(self, "cwd", None)
if cwd is None:
cwd = local.cwd
if env is None:
env = getattr(self, "env", None)
if env is None:
env = local.env
if hasattr(env, "getdict"):
env = env.getdict()
argv = self.formulate(0, args)
local_logger.debug("Running %r", argv)
proc = Popen(argv, executable = str(self.executable), stdin = stdin, stdout = stdout,
stderr = stderr, cwd = str(cwd), env = env, **kwargs) #bufsize = 4096
proc.encoding = self.encoding
proc.argv = argv
return proc
示例3: _popen
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import argv [as 别名]
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 subprocess.mswindows:
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 subprocess.mswindows and "startupinfo" not in kwargs and stdin not in (sys.stdin, None):
kwargs["startupinfo"] = sui = subprocess.STARTUPINFO()
if hasattr(subprocess, "_subprocess"):
sui.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW # @UndefinedVariable
sui.wShowWindow = subprocess._subprocess.SW_HIDE # @UndefinedVariable
else:
sui.dwFlags |= subprocess.STARTF_USESHOWWINDOW # @UndefinedVariable
sui.wShowWindow = subprocess.SW_HIDE # @UndefinedVariable
if not has_new_subprocess and "close_fds" not in kwargs:
if subprocess.mswindows and (stdin is not None or stdout is not None or stderr is not None):
# we can't close fds if we're on windows and we want to redirect any std handle
kwargs["close_fds"] = False
else:
kwargs["close_fds"] = True
if cwd is None:
cwd = self.cwd
if env is None:
env = self.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 = Popen(
argv, executable=str(executable), stdin=stdin, stdout=stdout, stderr=stderr, cwd=str(cwd), env=env, **kwargs
) # bufsize = 4096
proc._start_time = time.time()
proc.encoding = self.encoding
proc.argv = argv
return proc