Changeset 432


Ignore:
Timestamp:
23-03-11 20:40:47 (2 years ago)
Author:
thomas
Message:
  • morituri/program/cdparanoia.py: cdparanoia can hang indefinitely on scsi read errors. For example, on some drives, when trying negative offsets. Notice them, count them, and fail after 100.
  • morituri/test/test_program_cdparanoia.py:
  • morituri/test/cdparanoia.progress.error (added): Add a test for this output.
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r431 r432  
     12011-03-23  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * morituri/program/cdparanoia.py: 
     4          cdparanoia can hang indefinitely on scsi read errors. 
     5          For example, on some drives, when trying negative offsets. 
     6          Notice them, count them, and fail after 100. 
     7        * morituri/test/test_program_cdparanoia.py: 
     8        * morituri/test/cdparanoia.progress.error (added): 
     9          Add a test for this output. 
     10 
     112011-03-23  Thomas Vander Stichele  <thomas at apestaart dot org> 
     12 
     13        * morituri/program/cdparanoia.py: 
     14        * morituri/test/test_program_cdparanoia.py: 
     15           
     16 
    1172011-03-22  Thomas Vander Stichele  <thomas at apestaart dot org> 
    218 
  • trunk/morituri/program/cdparanoia.py

    r428 r432  
    3232 
    3333class FileSizeError(Exception): 
     34 
     35    message = None 
     36 
    3437    """ 
    3538    The given path does not have the expected size. 
     
    5457""", re.VERBOSE) 
    5558 
     59_ERROR_RE = re.compile("^scsi_read error:") 
     60 
    5661# from reading cdparanoia source code, it looks like offset is reported in 
    5762# number of single-channel samples, ie. 2 bytes per unit, and absolute 
     
    6065    read = 0 # last [read] frame 
    6166    wrote = 0 # last [wrote] frame 
     67    errors = 0 # count of number of scsi errors 
    6268    _nframes = None # number of frames read on each [read] 
    6369    _firstFrames = None # number of frames read on first [read] 
     
    9399            elif function == 'wrote': 
    94100                self._parse_wrote(wordOffset) 
     101 
     102        m = _ERROR_RE.search(line) 
     103        if m: 
     104            self.errors += 1 
    95105 
    96106    def _parse_read(self, wordOffset): 
     
    180190    description = "Reading Track" 
    181191    quality = None # set at end of reading 
     192 
     193    _MAXERROR = 100 # number of errors detected by parser 
    182194 
    183195    def __init__(self, path, table, start, stop, offset=0, device=None): 
     
    283295                self._parser.parse(line) 
    284296 
     297            # fail if too many errors 
     298            if self._parser.errors > self._MAXERROR: 
     299                self.debug('%d errors, terminating', self._parser.errors) 
     300                self._popen.terminate() 
     301 
    285302            num = float(self._parser.wrote) - self._start 
    286303            den = float(self._stop) - self._start 
  • trunk/morituri/test/test_program_cdparanoia.py

    r254 r432  
    2323        q = '%.01f %%' % (self._parser.getTrackQuality() * 100.0, ) 
    2424        self.assertEquals(q, '99.7 %') 
     25 
     26class ErrorTestCase(unittest.TestCase): 
     27 
     28    def setUp(self): 
     29        # report from a rip with offset -1164 causing scsi errors 
     30        path = os.path.join(os.path.dirname(__file__), 
     31            'cdparanoia.progress.error') 
     32        self._parser = cdparanoia.ProgressParser(start=0, stop=10800) 
     33 
     34        self._handle = open(path) 
     35 
     36    def testParse(self): 
     37        for line in self._handle.readlines(): 
     38            self._parser.parse(line) 
     39 
     40        q = '%.01f %%' % (self._parser.getTrackQuality() * 100.0, ) 
     41        self.assertEquals(q, '99.7 %') 
     42 
Note: See TracChangeset for help on using the changeset viewer.