本文整理汇总了Python中subprocess.CalledProcessError.stdout方法的典型用法代码示例。如果您正苦于以下问题:Python CalledProcessError.stdout方法的具体用法?Python CalledProcessError.stdout怎么用?Python CalledProcessError.stdout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.CalledProcessError
的用法示例。
在下文中一共展示了CalledProcessError.stdout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __lt__
# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stdout [as 别名]
def __lt__(self,other):
cmd = self.__get_recursive_name()
#print " ",cmd,"<",other
popen = subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
m = popen.communicate(other)
ret = popen.wait()
if ret:
e = CalledProcessError(ret,cmd)
e.stdout,e.stderr = m
raise e
class CommandOutput:
def __init__(self,stdout,stderr):
self.stdout = stdout
self.stderr = stderr
return CommandOutput(*m)
示例2: check_output
# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stdout [as 别名]
def check_output(run_args, *args, **kwargs):
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
process = Popen(run_args, *args, **kwargs)
stdout, stderr = process.communicate()
retcode = process.poll()
if retcode is not 0:
exception = CalledProcessError(retcode, run_args[0])
exception.stdout = stdout
exception.stderr = stderr
raise exception
return stdout, stderr
示例3: check_call_capturing
# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stdout [as 别名]
def check_call_capturing(arguments, input = None, preexec_fn = None):
"""Spawn a process and return its output."""
(stdout, stderr, code) = call_capturing(arguments, input, preexec_fn)
if code == 0:
return (stdout, stderr)
else:
from subprocess import CalledProcessError
error = CalledProcessError(code, arguments)
error.stdout = stdout
error.stderr = stderr
raise error
示例4: __call__
# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stdout [as 别名]
def __call__(self,*args,**kwargs):
cmd = self.__get_recursive_name() + list(args)
#print " ",cmd
kwargs = dict(kwargs)
if "stdout" not in kwargs: kwargs["stdout"] = subprocess.PIPE
if "stderr" not in kwargs: kwargs["stderr"] = subprocess.PIPE
popen = subprocess.Popen(cmd,**kwargs)
m = popen.communicate()
ret = popen.wait()
if ret:
e = CalledProcessError(ret,cmd)
e.stdout,e.stderr = m
raise e
class CommandOutput:
def __init__(self,stdout,stderr):
self.stdout = stdout
self.stderr = stderr
return CommandOutput(*m)
示例5: __submit
# 需要导入模块: from subprocess import CalledProcessError [as 别名]
# 或者: from subprocess.CalledProcessError import stdout [as 别名]
def __submit(self, call, env):
output_chunks = []
process = Popen(call, env=env, stderr=STDOUT, stdout=PIPE)
while process.returncode is None:
output_chunks.append(process.communicate())
sleep(0.1)
stdout = "".join([c[0].decode('utf-8') for c in output_chunks if c[0] is not None])
stderr = "".join([c[1].decode('utf-8') for c in output_chunks if c[1] is not None])
if process.returncode == 0:
return stdout, stderr
exc = CalledProcessError(process.returncode, call)
exc.stdout = stdout
exc.stderr = stderr
print(stdout)
print(stderr)
raise exc