[SCM] morituri/master: verify cdparanoia's output
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:53 UTC 2014
The following commit has been merged in the master branch:
commit 81eddd26b8bbe25a52afc4f4abb61bd70a2c9f07
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sun May 3 14:54:52 2009 +0000
verify cdparanoia's output
diff --git a/examples/ARcalibrate.py b/examples/ARcalibrate.py
index 76a597e..2844e6d 100644
--- a/examples/ARcalibrate.py
+++ b/examples/ARcalibrate.py
@@ -27,10 +27,9 @@ import optparse
import gobject
gobject.threads_init()
-import gtk
from morituri.image import image
-from morituri.common import task, taskgtk, checksum
+from morituri.common import task, checksum
from morituri.program import cdrdao, cdparanoia
"""
@@ -41,6 +40,7 @@ from morituri.common import log
log.init()
def gtkmain(runner, taskk):
+ import gtk
runner.connect('stop', lambda _: gtk.main_quit())
window = gtk.Window()
@@ -112,6 +112,7 @@ def main(argv):
runner = task.SyncRunner()
function = climain
elif options.runner == 'gtk':
+ from morituri.common import taskgtk
runner = taskgtk.GtkProgressRunner()
function = gtkmain
diff --git a/examples/readtrack.py b/examples/readtrack.py
index 0301496..4b41c8e 100644
--- a/examples/readtrack.py
+++ b/examples/readtrack.py
@@ -3,10 +3,12 @@
import re
import os
+import stat
import subprocess
import tempfile
from morituri.common import task, checksum, log
+from morituri.image import table
from morituri.program import cdparanoia
import gobject
@@ -21,7 +23,12 @@ def main():
fd, path = tempfile.mkstemp(suffix='.morituri')
os.close(fd)
- t = cdparanoia.ReadTrackTask(path, 1000, 3000, offset=0)
+ fakeTable = table.Table([
+ table.Track( 1, 0, 15536),
+ ])
+
+ t = cdparanoia.ReadTrackTask(path, fakeTable, 1000, 3000, offset=0)
+
if i == 1:
t.description = 'Verifying track...'
diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py
index e84bc0d..01c4a4c 100644
--- a/morituri/program/cdparanoia.py
+++ b/morituri/program/cdparanoia.py
@@ -20,10 +20,12 @@
# You should have received a copy of the GNU General Public License
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
+import os
import re
+import stat
import subprocess
-from morituri.common import task, log, common
+from morituri.common import task, log, common, checksum
from morituri.extern import asyncsub
_PROGRESS_RE = re.compile(r"""
@@ -70,8 +72,8 @@ class ReadTrackTask(task.Task):
@type path: str
@param table: table of contents of CD
@type table: L{table.Table}
- @param start: first frame to rip, in cdparanoia notation
- @type start: str
+ @param start: first frame to rip
+ @type start: int
@param stop: last frame to rip (inclusive)
@type stop: int
@param offset: read offset, in samples
@@ -91,10 +93,10 @@ class ReadTrackTask(task.Task):
task.Task.start(self, runner)
# find on which track the range starts and stops
- startTrack = 0
+ startTrack = 1
startOffset = 0
- stopTrack = 0
- stopOffset = 0
+ stopTrack = 1
+ stopOffset = self._stop
for i, t in enumerate(self._table.tracks):
if t.start <= self._start:
@@ -168,12 +170,27 @@ class ReadTrackTask(task.Task):
self._done()
def _done(self):
- self.setProgress(1.0)
- if self._popen.returncode != 0:
- if self._errors:
- print "\n".join(self._errors)
- else:
- print 'ERROR: exit code %r' % self._popen.returncode
-
- self.stop()
- return
+ self.setProgress(1.0)
+
+ # check if the length matches
+ size = os.stat(self.path)[stat.ST_SIZE]
+ # wav header is 44 bytes
+ offsetLength = self._stop - self._start + 1
+ expected = offsetLength * checksum.BYTES_PER_FRAME + 44
+ if size != expected:
+ print 'ERROR: file size %d did not match expected size %d' % (
+ size, expected)
+ if (size - expected) % checksum.BYTES_PER_FRAME == 0:
+ print 'ERROR: %d frames difference' % (
+ (size - expected) / checksum.BYTES_PER_FRAME)
+ else:
+ print 'SIZE %d matches offset delta %d' % (size, self._stop - self._start)
+
+ if self._popen.returncode != 0:
+ if self._errors:
+ print "\n".join(self._errors)
+ else:
+ print 'ERROR: exit code %r' % self._popen.returncode
+
+ self.stop()
+ return
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list