本文整理汇总了Python中popen2.Popen4方法的典型用法代码示例。如果您正苦于以下问题:Python popen2.Popen4方法的具体用法?Python popen2.Popen4怎么用?Python popen2.Popen4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popen2
的用法示例。
在下文中一共展示了popen2.Popen4方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exec_command
# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen4 [as 别名]
def exec_command(cmd, ok_return_value=0, combine_error=False):
"""
Run given command, check return value, and return
concatenated stdout and stderr.
"""
# XXX: unix-only!
try:
p = popen2.Popen4(cmd, True)
p.tochild.close()
returncode = p.wait() >> 8
out = p.fromchild.read()
except OSError, e:
raise RuntimeError("Command %s failed: %s" % (' '.join(cmd), e))
示例2: __init__
# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen4 [as 别名]
def __init__(self, command, **kw):
if kw.get('stderr') == 'STDOUT':
popen2.Popen4.__init__(self, command, 1)
else:
popen2.Popen3.__init__(self, command, 1)
self.stdin = self.tochild
self.stdout = self.fromchild
self.stderr = self.childerr
示例3: __init__
# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen4 [as 别名]
def __init__(self, command, **kw):
if kw.get('stderr') == 'STDOUT':
apply(popen2.Popen4.__init__, (self, command, 1))
else:
apply(popen2.Popen3.__init__, (self, command, 1))
self.stdin = self.tochild
self.stdout = self.fromchild
self.stderr = self.childerr
示例4: __init__
# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen4 [as 别名]
def __init__(self, cmd, bufsize=-1, shell=True, close_fds=True,
stdin=PIPE, stdout=PIPE, stderr=STDOUT, **kwargs):
super(Popen4, self).__init__(cmd, bufsize=bufsize, shell=shell,
close_fds=close_fds, stdin=stdin, stdout=stdout,
stderr=stderr, **kwargs)
self.tochild = self.stdin
self.fromchild = self.stdout
self.childerr = self.stderr
示例5: assertPosixSubprocess
# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import Popen4 [as 别名]
def assertPosixSubprocess(self, cmd):
cmd = cmd.replace('cheetah', self.cmd)
process = Popen4(cmd, env=os.environ)
process.tochild.close()
output = process.fromchild.read()
status = process.wait()
process.fromchild.close()
return status, output