From f70ba7cb322303d8b9d579b72c0f8808501f788c Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 19 May 2011 00:28:36 +0000 Subject: [PATCH] * morituri/program/cdparanoia.py: * morituri/common/encode.py: * morituri/common/program.py: * morituri/rip/cd.py: Add action and what args to describe task better. --- ChangeLog | 8 ++++++++ morituri/common/encode.py | 12 +++++++++--- morituri/common/program.py | 10 +++++++--- morituri/program/cdparanoia.py | 20 +++++++++++++------- morituri/rip/cd.py | 3 ++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24641b0..3f66529 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-05-19 Thomas Vander Stichele + + * morituri/program/cdparanoia.py: + * morituri/common/encode.py: + * morituri/common/program.py: + * morituri/rip/cd.py: + Add action and what args to describe task better. + 2011-05-19 Thomas Vander Stichele * morituri/common/task.py: diff --git a/morituri/common/encode.py b/morituri/common/encode.py index 8aaf7e0..a3d64a7 100644 --- a/morituri/common/encode.py +++ b/morituri/common/encode.py @@ -137,7 +137,7 @@ class EncodeTask(task.Task): description = 'Encoding' peak = None - def __init__(self, inpath, outpath, profile, taglist=None): + def __init__(self, inpath, outpath, profile, taglist=None, what="track"): """ @param profile: encoding profile @type profile: L{Profile} @@ -154,6 +154,7 @@ class EncodeTask(task.Task): self._peakdB = None self._profile = profile + self.description = "Encoding %s" % what self._profile.test() def start(self, runner): @@ -162,7 +163,7 @@ class EncodeTask(task.Task): # here to avoid import gst eating our options import gst - self._pipeline = gst.parse_launch(''' + desc = ''' filesrc location="%s" ! decodebin name=decoder ! audio/x-raw-int,width=16,depth=16,channels=2 ! @@ -171,7 +172,10 @@ class EncodeTask(task.Task): filesink location="%s" name=sink''' % ( common.quoteParse(self._inpath).encode('utf-8'), self._profile.pipeline, - common.quoteParse(self._outpath).encode('utf-8'))) + common.quoteParse(self._outpath).encode('utf-8')) + + self.debug('creating pipeline: %r', desc) + self._pipeline = gst.parse_launch(desc) tagger = self._pipeline.get_by_name('tagger') @@ -272,6 +276,8 @@ class EncodeTask(task.Task): self.debug('setting state to NULL') self._pipeline.set_state(gst.STATE_NULL) self.debug('set state to NULL') + # FIXME: maybe this should move lower ? If used by BaseMultiTask, + # this starts the next task without showing us the peakdB task.Task.stop(self) if self._peakdB is not None: diff --git a/morituri/common/program.py b/morituri/common/program.py index 9ea1b48..90a29f2 100644 --- a/morituri/common/program.py +++ b/morituri/common/program.py @@ -461,7 +461,8 @@ class Program(log.Loggable): return trackResult.testcrc == t.checksum - def ripTrack(self, runner, trackResult, offset, device, profile, taglist): + def ripTrack(self, runner, trackResult, offset, device, profile, taglist, + what=None): """ @param trackResult: the object to store information in. @type trackResult: L{result.TrackResult} @@ -478,13 +479,16 @@ class Program(log.Loggable): if not os.path.exists(dirname): os.makedirs(dirname) + if not what: + what='track %d' % (trackResult.number, ) + t = cdparanoia.ReadVerifyTrackTask(trackResult.filename, self.result.table, start, stop, offset=offset, device=device, profile=profile, - taglist=taglist) - t.description = 'Reading Track %d' % trackResult.number + taglist=taglist, + what=what) runner.run(t) diff --git a/morituri/program/cdparanoia.py b/morituri/program/cdparanoia.py index 093fb76..dc23a5b 100644 --- a/morituri/program/cdparanoia.py +++ b/morituri/program/cdparanoia.py @@ -187,12 +187,13 @@ class ReadTrackTask(task.Task): @ivar reads: how many reads were done to rip the track """ - description = "Reading Track" + description = "Reading track" quality = None # set at end of reading _MAXERROR = 100 # number of errors detected by parser - def __init__(self, path, table, start, stop, offset=0, device=None): + def __init__(self, path, table, start, stop, offset=0, device=None, + action="Reading", what="track"): """ Read the given track. @@ -208,6 +209,10 @@ class ReadTrackTask(task.Task): @type offset: int @param device: the device to rip from @type device: str + @param action: a string representing the action; e.g. Read/Verify + @type action: str + @param what: a string representing what's being read; e.g. Track + @type what: str """ assert type(path) is unicode, "%r is not unicode" % path @@ -221,6 +226,7 @@ class ReadTrackTask(task.Task): self._buffer = "" # accumulate characters self._errors = [] + self.description = "%s %s" % (action, what) def start(self, runner): task.Task.start(self, runner) @@ -371,7 +377,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask): _tmppath = None def __init__(self, path, table, start, stop, offset=0, device=None, - profile=None, taglist=None): + profile=None, taglist=None, what="track"): """ @param path: where to store the ripped track @type path: str @@ -392,6 +398,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask): """ task.MultiSeparateTask.__init__(self) + self.debug('Creating read and verify task on %r', path) self.path = path if taglist: @@ -408,11 +415,10 @@ class ReadVerifyTrackTask(task.MultiSeparateTask): self.tasks = [] self.tasks.append( ReadTrackTask(tmppath, table, start, stop, - offset=offset, device=device)) + offset=offset, device=device, what=what)) self.tasks.append(checksum.CRC32Task(tmppath)) t = ReadTrackTask(tmppath, table, start, stop, - offset=offset, device=device) - t.description = 'Verifying track...' + offset=offset, device=device, action="Verifying", what=what) self.tasks.append(t) self.tasks.append(checksum.CRC32Task(tmppath)) @@ -426,7 +432,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask): from morituri.common import encode self.tasks.append(encode.EncodeTask(tmppath, tmpoutpath, profile, - taglist=taglist)) + taglist=taglist, what=what)) # make sure our encoding is accurate self.tasks.append(checksum.CRC32Task(tmpoutpath)) diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 0557e2c..cbc8ed4 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -215,7 +215,8 @@ See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=1 offset=int(self.options.offset), device=self.parentCommand.options.device, profile=profile, - taglist=prog.getTagList(number)) + taglist=prog.getTagList(number), + what='track %d of %d' % (number, len(itable.tracks))) if trackResult.testcrc == trackResult.copycrc: print 'Checksums match for track %d' % (number)