* morituri/program/cdparanoia.py:

* morituri/test/test_program_cdparanoia.py:
	  Add a task that can analyze the drive for whether it defeats
	  the audio cache.
	* morituri/result/result.py:
	* morituri/rip/cd.py:
	  Make it possible to store whether a drive defeats audio cache
	  in the result.
	* morituri/rip/drive.py:
	  Add rip drive analyze command to analyze caching of a drive,
	  and store it in the config.
This commit is contained in:
Thomas Vander Stichele
2012-12-04 00:14:42 +00:00
parent cec7f71502
commit 4647d107a9
6 changed files with 150 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ import subprocess
import tempfile
from morituri.common import log, common
from morituri.common import task as ctask
from morituri.extern import asyncsub
from morituri.extern.task import task
@@ -562,3 +563,45 @@ def getCdParanoiaVersion():
raise
return version
_OK_RE = re.compile(r'Drive tests OK with Paranoia.')
class AnalyzeTask(ctask.PopenTask):
logCategory = 'AnalyzeTask'
description = 'Analyzing drive caching behaviour'
defeatsCache = None
cwd = None
_output = []
def __init__(self, device=None):
# cdparanoia -A *always* writes cdparanoia.log
self.cwd = tempfile.mkdtemp(suffix='.morituri.cache')
self.command = ['cdparanoia', '-A']
if device:
self.command += ['-d', device]
def commandMissing(self):
raise common.MissingDependencyException('cdparanoia')
def readbyteserr(self, bytes):
self._output.append(bytes)
def done(self):
if self.cwd:
shutil.rmtree(self.cwd)
output = "".join(self._output)
m = _OK_RE.search(output)
if m:
self.defeatsCache = True
else:
self.defeatsCache = False
def failed(self):
if self.cwd:
shutil.rmtree(self.cwd)