Skip to content

Commit

Permalink
Add config file option to set cdparanoia command
Browse files Browse the repository at this point in the history
Resolves whipper-team#220
Partially addresses whipper-team#244
Provides workaround for whipper-team#234

Signed-off-by: Evan Harris <[email protected]>
  • Loading branch information
eharris committed Sep 15, 2022
1 parent 6ad681a commit c7d02d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions whipper/command/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 11 additions & 4 deletions whipper/program/cdparanoia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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, ])
Expand Down Expand Up @@ -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")

Expand All @@ -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]

Expand Down

0 comments on commit c7d02d3

Please sign in to comment.