Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module writer :: Class CdWriter |
|
object
--+
|
CdWriter
This is a class representing a device that knows how to write CD media. It provides common operations for the device, such as ejecting the media, writing an ISO image to the media, or checking for the current media capacity. It also provides a place to store device attributes, such as whether the device supports writing multisession discs, etc.
This class is implemented in terms of the eject
and
cdrecord
programs, both of which should be available on
most UN*X platforms.
MEDIA_CDR_74
: 74-minute CD-R media (650 MB
capacity)
MEDIA_CDRW_74
: 74-minute CD-RW media (650 MB
capacity)
MEDIA_CDR_80
: 80-minute CD-R media (700 MB
capacity)
MEDIA_CDRW_80
: 80-minute CD-RW media (700 MB
capacity)
Most hardware can read and write both 74-minute and 80-minute CD-R and CD-RW media. Some older drives may only be able to write CD-R media. The difference between the two is that CD-RW media can be rewritten (erased), while CD-R media cannot be.
I do not support any other configurations for a couple of reasons. The first is that I've never tested any other kind of media. The second is that anything other than 74 or 80 minute is apparently non-standard.This class needs to talk to CD writer hardware in two different ways: through cdrecord to actually write to the media, and through the filesystem to do things like open and close the tray.
Historically, CdWriter has interacted with cdrecord using the scsiId attribute, and with most other utilities using the device attribute. This changed somewhat in Cedar Backup 2.9.0.
When Cedar Backup was first written, the only way to interact with
cdrecord was by using a SCSI device id. IDE devices were mapped to
pseudo-SCSI devices through the kernel. Later, extended SCSI
"methods" arrived, and it became common to see
ATA:1,0,0
or ATAPI:0,0,0
as a way to address
IDE hardware. By late 2006, ATA
and ATAPI
had
apparently been deprecated in favor of just addressing the IDE device
directly by name, i.e. /dev/cdrw
.
dev=
argument.
It's rather difficult to test this code in an automated fashion, even if you have access to a physical CD writer drive. It's even more difficult to test it if you are running on some build daemon (think of a Debian autobuilder) which can't be expected to have any hardware or any media that you could write to.
Because of this, much of the implementation below is in terms of static methods that are supposed to take defined actions based on their arguments. Public methods are then implemented in terms of a series of calls to simplistic static methods. This way, we can test as much as possible of the functionality via testing the static methods, while hoping that if the static methods are called appropriately, things will work properly. It's not perfect, but it's much better than no testing at all.Method Summary | |
---|---|
Initializes a CD writer object. | |
Indicates whether the media is rewritable per configuration. | |
Retrieves capacity for the current media in terms of a MediaCapacity object. | |
Opens the device's tray and leaves it open. | |
Closes the device's tray. | |
Opens and then immediately closes the device's tray, to refresh the device's idea of the media. | |
Writes an ISO image to the media in the device. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Property Summary | |
---|---|
device : Filesystem device name for this writer. | |
scsiId : SCSI id for the device, in the form
[<method>:]scsibus,target,lun . | |
hardwareId : Hardware id for this writer, either SCSI id or device path. | |
driveSpeed : Speed at which the drive writes. | |
media : Definition of media that is expected to be in the device. | |
deviceType : Type of the device, as returned from cdrecord -prcap . | |
deviceVendor : Vendor of the device, as returned from cdrecord
-prcap . | |
deviceId : Device identification, as returned from cdrecord
-prcap . | |
deviceBufferSize : Size of the device's write buffer, in bytes. | |
deviceSupportsMulti : Indicates whether device supports multisession discs. | |
deviceHasTray : Indicates whether the device has a media tray. | |
deviceCanEject : Indicates whether the device supports ejecting its media. |
Instance Method Details |
---|
__init__(self,
device,
scsiId,
driveSpeed=None,
mediaType=1,
unittest=False)
|
isRewritable(self)Indicates whether the media is rewritable per configuration. |
retrieveCapacity(self, entireDisc=False, useMulti=True)Retrieves capacity for the current media in terms of a
entireDisc is passed in as True the
capacity will be for the entire disc, as if it were to be rewritten
from scratch. If the drive does not support writing multisession discs
or if useMulti is passed in as False , the
capacity will also be as if the disc were to be rewritten from scratch,
but the indicated boundaries value will be None . The same
will happen if the disc cannot be read for some reason. Otherwise, the
capacity (including the boundaries) will represent whatever space
remains on the disc to be filled by future sessions.
|
openTray(self)Opens the device's tray and leaves it open. This only works if the device has a tray and supports ejecting its media. We have no way to know if the tray is currently open or closed, so we just send the appropriate command and hope for the best. If the device does not have a tray or does not support ejecting its media, then we do nothing.
|
closeTray(self)Closes the device's tray. This only works if the device has a tray and supports ejecting its media. We have no way to know if the tray is currently open or closed, so we just send the appropriate command and hope for the best. If the device does not have a tray or does not support ejecting its media, then we do nothing.
|
refreshMedia(self)Opens and then immediately closes the device's tray, to refresh the device's idea of the media. Sometimes, a device gets confused about the state of its media. Often, all it takes to solve the problem is to eject the media and then immediately reload it. This only works if the device has a tray and supports ejecting its media. We have no way to know if the tray is currently open or closed, so we just send the appropriate command and hope for the best. If the device does not have a tray or does not support ejecting its media, then we do nothing.
|
writeImage(self, imagePath, newDisc=False, writeMulti=True)Writes an ISO image to the media in the device. If If
|
Property Details |
---|
deviceFilesystem device name for this writer. |
scsiIdSCSI id for the device, in the form[<method>:]scsibus,target,lun .
|
hardwareIdHardware id for this writer, either SCSI id or device path. |
driveSpeedSpeed at which the drive writes. |
mediaDefinition of media that is expected to be in the device. |
deviceTypeType of the device, as returned fromcdrecord -prcap .
|
deviceVendorVendor of the device, as returned fromcdrecord
-prcap .
|
deviceIdDevice identification, as returned fromcdrecord
-prcap .
|
deviceBufferSizeSize of the device's write buffer, in bytes. |
deviceSupportsMultiIndicates whether device supports multisession discs. |
deviceHasTrayIndicates whether the device has a media tray. |
deviceCanEjectIndicates whether the device supports ejecting its media. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Dec 18 22:53:31 2006 | http://epydoc.sf.net |