From 1e980db4ef5f54e73a006bda2530c7cef8cbb802 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 2 Dec 2012 12:18:15 +0000 Subject: [PATCH] * morituri/rip/main.py: Add the config object to the root command. * morituri/rip/offset.py: Save the drive's read offset when we find it. --- ChangeLog | 7 +++++++ morituri/rip/main.py | 4 +++- morituri/rip/offset.py | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2d1bf2..fda3ae2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-12-02 Thomas Vander Stichele + + * morituri/rip/main.py: + Add the config object to the root command. + * morituri/rip/offset.py: + Save the drive's read offset when we find it. + 2012-12-02 Thomas Vander Stichele * morituri.spec.in: diff --git a/morituri/rip/main.py b/morituri/rip/main.py index 60d13a8..bab3b8c 100644 --- a/morituri/rip/main.py +++ b/morituri/rip/main.py @@ -5,7 +5,7 @@ import os import sys import pkg_resources -from morituri.common import log, logcommand, common +from morituri.common import log, logcommand, common, config from morituri.rip import cd, offset, drive, image, accurip, debug @@ -104,6 +104,8 @@ You can get help on subcommands by using the -h option to the subcommand. self.record = options.record + self.config = config.Config() + def parse(self, argv): log.debug("morituri", "rip %s" % " ".join(argv)) logcommand.LogCommand.parse(self, argv) diff --git a/morituri/rip/offset.py b/morituri/rip/offset.py index 39f55a6..03acdf6 100644 --- a/morituri/rip/offset.py +++ b/morituri/rip/offset.py @@ -188,8 +188,7 @@ CD in the AccurateRip database.""" count += 1 if count == len(table.tracks): - self.stdout.write('\nRead offset of device is: %d.\n' % - offset) + self._foundOffset(device, offset) return 0 else: self.stdout.write( @@ -225,6 +224,20 @@ CD in the AccurateRip database.""" os.unlink(path) return "%08x" % t.checksum + def _foundOffset(self, device, offset): + self.stdout.write('\nRead offset of device is: %d.\n' % + offset) + + info = drive.getDeviceInfo(device) + if not info: + return + + self.stdout.write('Adding read offset to configuration file.\n') + + self.getRootCommand().config.setReadOffset(info[0], info[1], info[2], + offset) + + class Offset(logcommand.LogCommand): summary = "handle drive offsets"