whipper icon indicating copy to clipboard operation
whipper copied to clipboard

Not possible to see `whipper cd` --help messages without optical drive

Open Freso opened this issue 7 years ago • 7 comments

Trying to get --help for whipper cd or any of its subcommands (well, rip at least) fails when there's no CD-DA drive:

~> whipper cd --help
CRITICAL:whipper.command.basecommand:No CD-DA drives found!
Traceback (most recent call last):
  File "/usr/bin/whipper", line 11, in <module>
    load_entry_point('whipper==0.5.1', 'console_scripts', 'whipper')()
  File "/usr/lib/python2.7/site-packages/whipper/command/main.py", line 31, in main
    cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None)
  File "/usr/lib/python2.7/site-packages/whipper/command/basecommand.py", line 102, in __init__
    self.options
  File "/usr/lib/python2.7/site-packages/whipper/command/basecommand.py", line 72, in __init__
    raise IOError(msg)
IOError: No CD-DA drives found!

Actual CD commands should definitely fail without a drive, but it should be possible to still get help messages.

(Using whipper at current master: https://github.com/JoeLametta/whipper/commit/5e4303fdbf7b3910122785864b1d2cdc4e14b03b )

Freso avatar Jun 04 '17 03:06 Freso

This is obnoxious, the entire command structure makes it hard to quickly fix this. Trying to get any defaults before parsing options is just not cool.

MerlijnWajer avatar Jan 26 '18 22:01 MerlijnWajer

This makes the errors at least non-fatal:

From: Merlijn Wajer <[email protected]>
Date: Fri, 26 Jan 2018 23:56:29 +0100
Subject: [PATCH] Make drive getting non-fatal in option parsing

---
 whipper/command/basecommand.py | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/whipper/command/basecommand.py b/whipper/command/basecommand.py
index c89fd5a..1cd147c 100644
--- a/whipper/command/basecommand.py
+++ b/whipper/command/basecommand.py
@@ -78,16 +78,14 @@ class BaseCommand():
                 msg = 'No CD-DA drives found!'
                 logger.critical(msg)
                 # whipper exited with return code 3 here
-                raise IOError(msg)
-            self.options.device = drives[0]
-
-        if self.device_option:
-            # this can be a symlink to another device
-            self.options.device = os.path.realpath(self.options.device)
-            if not os.path.exists(self.options.device):
-                msg = 'CD-DA device %s not found!' % self.options.device
-                logger.critical(msg)
-                raise IOError(msg)
+                #raise IOError(msg)
+            else:
+                # this can be a symlink to another device
+                self.options.device = os.path.realpath(drives[0])
+                if not os.path.exists(self.options.device):
+                    msg = 'CD-DA device %s not found!' % self.options.device
+                    logger.critical(msg)
+                    #raise IOError(msg)
 
         self.handle_arguments()
 
-- 
2.15.1

MerlijnWajer avatar Jan 26 '18 22:01 MerlijnWajer

whipper --help and almost all the subcommands's --help work now, only whipper cd --help still doesn't work.

Freso avatar Feb 13 '19 23:02 Freso

Is this still the case?

JoeLametta avatar Sep 18 '20 07:09 JoeLametta

Still the case as of v0.9.0, didn't test master:

[tarulia@fedora]~% whipper cd --help
CRITICAL:whipper.command.basecommand:No CD-DA drives found!
Traceback (most recent call last):
  File "/usr/bin/whipper", line 33, in <module>
    sys.exit(load_entry_point('whipper==0.9.0', 'console_scripts', 'whipper')())
  File "/usr/lib64/python3.9/site-packages/whipper/command/main.py", line 42, in main
    cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None)
  File "/usr/lib64/python3.9/site-packages/whipper/command/basecommand.py", line 114, in __init__
    self.cmd = self.subcommands[self.options.remainder[0]](
  File "/usr/lib64/python3.9/site-packages/whipper/command/basecommand.py", line 87, in __init__
    raise IOError(msg)
OSError: No CD-DA drives found!
[tarulia@fedora]~% whipper -v
whipper 0.9.0

mihawk90 avatar Apr 16 '21 14:04 mihawk90

Also still the case on 9.1.dev118+g84e4ef6 (installed through the AUR), i.e. 84e4ef6. A fix would be really nice!

wisp3rwind avatar May 01 '21 07:05 wisp3rwind

This "fixes" whipper cd --help and whipper cd info --help. whipper cd rip --help can be "fixed" too but it gets even more awful...

diff --git a/Documents/Programming/whipper/whipper/command/basecommand.py b/basecommand.py
index 64be91c..d4911ee 100644
--- a/Documents/Programming/whipper/whipper/command/basecommand.py
+++ b/basecommand.py
@@ -83,10 +83,11 @@ class BaseCommand:
             # pick the first drive as default
             drives = drive.getAllDevicePaths()
             if not drives:
+                drives = ['NO_DEVICES']
                 msg = 'No CD-DA drives found!'
                 logger.critical(msg)
                 # whipper exited with return code 3 here
-                raise IOError(msg)
+                #raise IOError(msg)
             self.parser.add_argument('-d', '--device',
                                      action="store",
                                      dest="device",
@@ -101,7 +102,7 @@ class BaseCommand:
             if not os.path.exists(self.options.device):
                 msg = 'CD-DA device %s not found!' % self.options.device
                 logger.critical(msg)
-                raise IOError(msg)
+                #raise IOError(msg)
 
         self.handle_arguments()

JoeLametta avatar May 14 '21 15:05 JoeLametta