本文整理汇总了Python中Process.Process.waitFor方法的典型用法代码示例。如果您正苦于以下问题:Python Process.waitFor方法的具体用法?Python Process.waitFor怎么用?Python Process.waitFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process.Process
的用法示例。
在下文中一共展示了Process.waitFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runExternalFilter
# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import waitFor [as 别名]
def runExternalFilter(self, inputStream, outputStream):
if self.__use_stdin:
inFile = None
else:
inFile = self.newTempFile("%s.in" % self.__class__.__name__)
Pump.stream2file(inputStream, inFile)
if self.__use_stdout:
outFile = None
else:
outFile = self.newTempFile("%s.out" % self.__class__.__name__)
cmd = self.getCommandLine(inFile, outFile)
try:
assert trace("Starting %s: %s" % (self.__name, cmd))
xfilter = Process(cmd, separate_stderr=self.__separate_stderr)
if self.__use_stdin:
assert trace("Writing file to %s stdin" % self.__name)
Pump.stream2stream(inputStream, xfilter.getInputStream())
if self.__use_stdout:
# output
assert trace("Pumping %s stdout to outputStream" % self.__name)
Pump.stream2stream(xfilter.getOutputStream(), outputStream)
if self.__separate_stderr:
assert trace("Handling %s stderr" % self.__name)
self.handleErrorOutput(xfilter.getErrorStream())
else:
assert trace("Handling %s stdout" % self.__name)
self.handleOutput(xfilter.getOutputStream())
if self.__separate_stderr:
assert trace("Handling %s stderr" % self.__name)
self.handleErrorOutput(xfilter.getErrorStream())
rc = xfilter.waitFor()
assert trace("%s finished with exit code: 0x%X" % (self.__name, rc))
if not (rc in self.__normalReturnCodes):
raise ExternalFilterException, "Return code 0x%X" % (rc,)
if not self.__use_stdout:
if os.path.exists(outFile):
try:
if os.path.getsize(outFile) > 0:
Pump.file2stream(outFile, outputStream, "b")
else:
raise ExternalFilterException, "Output file is empty: %s" % (outFile,)
finally:
self.removeTempFile(outFile)
else:
raise ExternalFilterException, "Output file not found: %s" % (outFile,)
finally:
if inFile is not None:
self.removeTempFile(inFile)
pass
return rc