cdrdao no-disc ejection & --eject (#93)

* cdrdao: eject empty disc while reading toc

- introduce EjectError
- move {eject,load,unmount}_device to program.utils

* remove duplicated eject

* remove unnecessary ejection

* add --eject option
This commit is contained in:
Samantha Baldwin
2017-01-01 13:41:23 -05:00
committed by JoeLametta
parent 17021a68f2
commit a1eb3377ea
7 changed files with 83 additions and 47 deletions

View File

@@ -12,6 +12,7 @@ from morituri.command import cd, offset, drive, image, accurip, debug
from morituri.command.basecommand import BaseCommand
from morituri.common import common, directory
from morituri.extern.task import task
from morituri.program.utils import eject_device
import logging
logger = logging.getLogger(__name__)
@@ -26,9 +27,13 @@ def main():
)
map(pkg_resources.working_set.add, distributions)
try:
ret = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None).do()
cmd = Whipper(sys.argv[1:], os.path.basename(sys.argv[0]), None)
ret = cmd.do()
except SystemError, e:
sys.stderr.write('whipper: error: %s\n' % e.args)
sys.stderr.write('whipper: error: %s\n' % e)
if (type(e) is common.EjectError and
cmd.options.eject in ('failure', 'always')):
eject_device(e.device)
return 255
except ImportError, e:
raise ImportError(e)
@@ -77,6 +82,10 @@ You can get help on subcommands by using the -h option to the subcommand.
self.parser.add_argument('-h', '--help',
action="store_true", dest="help",
help="show this help message and exit")
self.parser.add_argument('-e', '--eject',
action="store", dest="eject", default="always",
choices=('never', 'failure', 'success', 'always'),
help="when to eject disc (default: always)")
def handle_arguments(self):
if self.options.help: