From f623604da230a640be38572c3c3d19c649719c35 Mon Sep 17 00:00:00 2001 From: Evan Harris Date: Thu, 15 Sep 2022 04:31:57 -0500 Subject: [PATCH] Add config file option to set cdparanoia command Resolves #220 Partially addresses #244 Provides workaround for #234 Signed-off-by: Evan Harris --- whipper/command/main.py | 5 +++++ whipper/program/cdparanoia.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/whipper/command/main.py b/whipper/command/main.py index 8e06939a..7c54af1a 100644 --- a/whipper/command/main.py +++ b/whipper/command/main.py @@ -13,12 +13,17 @@ from whipper.common import common, directory, config from whipper.extern.task import task from whipper.program.utils import eject_device +from whipper.program import cdparanoia import logging logger = logging.getLogger(__name__) def main(): + cdparanoia_cmd = config.Config().get('main', 'cdparanoia') + if cdparanoia_cmd: + cdparanoia.setCdParanoiaCommand(cdparanoia_cmd) + server = config.Config().get_musicbrainz_server() https_enabled = server['scheme'] == 'https' try: diff --git a/whipper/program/cdparanoia.py b/whipper/program/cdparanoia.py index 5c4b7793..80fbe9c4 100644 --- a/whipper/program/cdparanoia.py +++ b/whipper/program/cdparanoia.py @@ -35,6 +35,7 @@ import logging logger = logging.getLogger(__name__) +cdparanoia = 'cd-paranoia' class FileSizeError(Exception): """The given path does not have the expected size.""" @@ -69,6 +70,12 @@ class ChecksumException(Exception): _ERROR_RE = re.compile("^scsi_read error:") + +def setCdParanoiaCommand(cmd): + global cdparanoia + cdparanoia = cmd + + # from reading cdparanoia source code, it looks like offset is reported in # number of single-channel samples, ie. 2 bytes (word) per unit, and absolute @@ -271,10 +278,10 @@ def start(self, runner): bufsize = 1024 if self._overread: - argv = ["cd-paranoia", "--stderr-progress", + argv = [cdparanoia, "--stderr-progress", "--sample-offset=%d" % self._offset, "--force-overread", ] else: - argv = ["cd-paranoia", "--stderr-progress", + argv = [cdparanoia, "--stderr-progress", "--sample-offset=%d" % self._offset, ] if self._device: argv.extend(["--force-cdrom-device", self._device, ]) @@ -573,7 +580,7 @@ def stop(self): def getCdParanoiaVersion(): getter = common.VersionGetter('cd-paranoia', - ["cd-paranoia", "-V"], + [cdparanoia, "-V"], _VERSION_RE, "%(version)s %(release)s") @@ -599,7 +606,7 @@ class AnalyzeTask(ctask.PopenTask): def __init__(self, device=None): # cdparanoia -A *always* writes cdparanoia.log self.cwd = tempfile.mkdtemp(suffix='.whipper.cache') - self.command = ['cd-paranoia', '-A'] + self.command = [cdparanoia, '-A'] if device: self.command += ['-d', device]