* morituri/common/task.py:
Log on runners too. * morituri/program/cdrdao.py: Abort if output has ERROR by killing and setting an exception.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
import re
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
@@ -30,6 +31,14 @@ from morituri.common import task, log
|
||||
from morituri.image import toc, table
|
||||
from morituri.extern import asyncsub
|
||||
|
||||
class ProgramError(Exception):
|
||||
"""
|
||||
The program had a fatal error.
|
||||
"""
|
||||
def __init__(self, message):
|
||||
self.args = (message, )
|
||||
self.message = message
|
||||
|
||||
states = ['START', 'TRACK', 'LEADOUT', 'DONE']
|
||||
|
||||
_ANALYZING_RE = re.compile(r'^Analyzing track (?P<track>\d+).*')
|
||||
@@ -118,7 +127,9 @@ class OutputParser(object, log.Loggable):
|
||||
for line in lines:
|
||||
self.log('Parsing %s', line)
|
||||
if line.startswith('ERROR:'):
|
||||
self._errors.append(line)
|
||||
self._task.exception = ProgramError(line)
|
||||
self._task.abort()
|
||||
return
|
||||
|
||||
self._parse(lines)
|
||||
self._lines.extend(lines)
|
||||
@@ -191,6 +202,7 @@ class CDRDAOTask(task.Task):
|
||||
bufsize=bufsize,
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
self.debug('Started cdrdao with pid %d', self._popen.pid)
|
||||
|
||||
self.runner.schedule(1.0, self._read, runner)
|
||||
|
||||
@@ -221,6 +233,11 @@ class CDRDAOTask(task.Task):
|
||||
self.stop()
|
||||
return
|
||||
|
||||
def abort(self):
|
||||
self.debug('Aborting, sending SIGTERM to %d', self._popen.pid)
|
||||
os.kill(self._popen.pid, signal.SIGTERM)
|
||||
self.stop()
|
||||
|
||||
def readbytes(self, bytes):
|
||||
"""
|
||||
Called when bytes have been read from stderr.
|
||||
|
||||
Reference in New Issue
Block a user