本文整理汇总了Python中subprocess.Popen.args方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.args方法的具体用法?Python Popen.args怎么用?Python Popen.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.args方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_bg
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_bg(cmd, **kargs):
if options.verbose:
print "run:", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
proc = Popen(args=args, **kargs)
proc.args = args
_add_proc(proc)
return proc
示例2: run_bg
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_bg(cmd, **kargs):
if options.verbose == 2:
logging.debug("run: %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
proc = Popen(args=args, **kargs)
proc.args = args
_add_proc(proc)
return proc
示例3: execute
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def execute(cmd, trap_output=False, verbose=False, **kargs):
args = shlex.split(cmd)
if trap_output:
kargs['stdout'] = PIPE
kargs['stderr'] = PIPE
if verbose:
print "Execute:", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems())
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode:
raise Exception('FAIL: %s %s %s' % (args, stdout, stderr))
return stdout, stderr
示例4: run_bg
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_bg(cmd, **kargs):
if options.verbose == 2:
logging.debug("run: %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
if 'extra_env' in kargs and kargs['extra_env']:
kargs['env'] = os.environ.copy()
kargs['env'].update(kargs['extra_env'])
del(kargs['extra_env'])
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
proc = Popen(args=args, **kargs)
proc.args = args
_add_proc(proc)
return proc
示例5: run_fail
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_fail(cmd, **kargs):
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
kargs['stdout'] = PIPE
kargs['stderr'] = PIPE
if options.verbose == 2:
logging.debug("run: (expect fail) %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode == 0:
logging.info("stdout:\n%sstderr:\n%s", stdout, stderr)
raise TestError('expected fail:', args, stdout, stderr)
return stdout, stderr
示例6: run_fail
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_fail(cmd, **kargs):
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
kargs["stdout"] = PIPE
kargs["stderr"] = PIPE
if options.verbose:
print "run: (expect fail)", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode == 0:
debug("stdout:\n" + stdout + "stderr:\n" + stderr)
raise TestError("expected fail:", args, stdout, stderr)
return stdout, stderr
示例7: run_bg
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run_bg(cmd, **kargs):
if options.verbose == 2:
logging.debug("run: %s %s", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems()))
if "extra_env" in kargs:
kargs["env"] = os.environ.copy()
if kargs["extra_env"]:
kargs["env"].update(kargs["extra_env"])
del (kargs["extra_env"])
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
proc = Popen(args=args, **kargs)
proc.args = args
_add_proc(proc)
return proc
示例8: run
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
if trap_output:
kargs['stdout'] = PIPE
kargs['stderr'] = PIPE
logging.debug("run: %s %s", str(cmd), ', '.join('%s=%s' % x for x in kargs.iteritems()))
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode:
if raise_on_error:
raise TestError('cmd fail:', args, stdout, stderr)
else:
logging.debug('cmd fail: %s %s %s', str(args), stdout, stderr)
return stdout, stderr
示例9: run
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
if trap_output:
kargs["stdout"] = PIPE
kargs["stderr"] = PIPE
logging.debug("run: %s %s", str(cmd), ", ".join("%s=%s" % x for x in kargs.iteritems()))
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode:
if raise_on_error:
pause("cmd fail: %s, pausing..." % (args))
raise TestError("cmd fail:", args, proc.returncode, stdout, stderr)
else:
logging.debug("cmd fail: %s %d %s %s", str(args), proc.returncode, stdout, stderr)
return stdout, stderr
示例10: run
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
if isinstance(cmd, str):
args = shlex.split(cmd)
else:
args = cmd
if trap_output:
kargs["stdout"] = PIPE
kargs["stderr"] = PIPE
if options.verbose:
print "run:", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode:
if raise_on_error:
raise TestError("cmd fail:", args, stdout, stderr)
else:
if options.verbose:
print "cmd fail:", args, stdout, stderr
return stdout, stderr
示例11: background
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import args [as 别名]
def background(*args):
"""Run executable in the backround, return the popen"""
p = Popen(cmdline(*args), stdout=PIPE, stderr=sys.stderr)
p.args = args # Save arguments for debugging output
return p