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:
committed by
JoeLametta
parent
17021a68f2
commit
a1eb3377ea
35
morituri/program/utils.py
Normal file
35
morituri/program/utils.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def eject_device(device):
|
||||
"""
|
||||
Eject the given device.
|
||||
"""
|
||||
logger.debug("ejecting device %s", device)
|
||||
os.system('eject %s' % device)
|
||||
|
||||
|
||||
def load_device(device):
|
||||
"""
|
||||
Load the given device.
|
||||
"""
|
||||
logger.debug("loading (eject -t) device %s", device)
|
||||
os.system('eject -t %s' % device)
|
||||
|
||||
|
||||
def unmount_device(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)
|
||||
Reference in New Issue
Block a user