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

@@ -39,6 +39,19 @@ WORDS_PER_FRAME = SAMPLES_PER_FRAME * 2
BYTES_PER_FRAME = SAMPLES_PER_FRAME * 4
class EjectError(SystemError):
"""
Possibly ejects the drive in command.main.
"""
def __init__(self, device, *args):
"""
args is a tuple used by BaseException.__str__
device is the device path to eject
"""
self.args = args
self.device = device
def msfToFrames(msf):
"""
Converts a string value in MM:SS:FF to frames.

View File

@@ -90,32 +90,6 @@ class Program:
logger.info('Changing to working directory %s' % workingDirectory)
os.chdir(workingDirectory)
def loadDevice(self, device):
"""
Load the given device.
"""
os.system('eject -t %s' % device)
def ejectDevice(self, device):
"""
Eject the given device.
"""
os.system('eject %s' % device)
def unmountDevice(self, device):
"""
Unmount the given device if it is mounted, as happens with automounted
data tracks.
If the given device is a symlink, the target will be checked.
"""
device = os.path.realpath(device)
logger.debug('possibly unmount real path %r' % device)
proc = open('/proc/mounts').read()
if device in proc:
print 'Device %s is mounted, unmounting' % device
os.system('umount %s' % device)
def getFastToc(self, runner, toc_pickle, device):
"""
Retrieve the normal TOC table from a toc pickle or the drive.