def run(self):
if self.finished:
return
self.process = subprocess.Popen(
[str(self.path)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True
)
LOG.info("Run %s. Pid %d", self.path, self.process.pid)
self.process.wait()
logmethod = LOG.info if self.process.returncode == os.EX_OK \
else LOG.warning
logmethod("%s has been finished. Exit code %s",
self.path, self.process.returncode)
self.stdout = self.process.stdout.read().decode("utf-8")
self.stderr = self.process.stderr.read().decode("utf-8")
if self.process.returncode != os.EX_OK:
raise RuntimeError(
"Program {0} has been finished with exit code {1}",
self.path, self.process.returncode)
评论列表
文章目录