Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Package writers :: Module dvdwriter :: Class DvdWriter |
|
object
--+
|
DvdWriter
This is a class representing a device that knows how to write some kinds of DVD media. It provides common operations for the device, such as ejecting the media and writing data to the media.
This class is implemented in terms of theeject
,
growisofs
and dvd+rw-mediainfo
utilities, all
of which should be available on most UN*X platforms.
__init__ initializeImage() addImageEntry() writeImage() setImageNewDisc() retrieveCapacity() getEstimatedImageSize()
Only these methods will be used by other Cedar Backup functionality that expects a compatible image writer.
The media attribute is also assumed to be available.
Unlike theCdWriter
, the DvdWriter
can
only operate in terms of filesystem devices, not SCSI devices. So,
although the constructor interface accepts a SCSI device parameter for
the sake of compatibility, it's not used.
MEDIA_DVDPLUSR
: DVD+R media (4.4 GB capacity)
MEDIA_DVDPLUSRW
: DVD+RW media (4.4 GB capacity)
The difference is that DVD+RW media can be rewritten, while DVD+R
media cannot be (although at present, DvdWriter
does not
really differentiate between rewritable and non-rewritable media).
The capacities are 4.4 GB because Cedar Backup deals in "true" gigabytes of 1024*1024*1024 bytes per gigabyte.
The underlyinggrowisofs
utility does support other
kinds of media (including DVD-R, DVD-RW and BlueRay) which work
somewhat differently than standard DVD+R and DVD+RW media. I don't
support these other kinds of media because I haven't had any
opportunity to work with them. The same goes for dual-layer media of
any type.
As with the cdwriter functionality, a given dvdwriter instance has two different kinds of attributes associated with it. I call these device attributes and media attributes.
Device attributes are things which can be determined without looking at the media. Media attributes are attributes which vary depending on the state of the media. In general, device attributes are available via instance variables and are constant over the life of an object, while media attributes can be retrieved through method calls.
Compared to cdwriters, dvdwriters have very few attributes. This is due to differences between the waygrowisofs
works
relative to cdrecord
.
One major difference between the
cdrecord
/mkisofs
utilities used by the
cdwriter class and the growisofs
utility used here is that
the process of estimating remaining capacity and image size is more
straightforward with cdrecord
/mkisofs
than
with growisofs
.
growisofs
and grabbing some information from
the output of that command. Image size is estimated by asking the
IsoImage
class for an estimate and then adding on a
"fudge factor" determined through experimentation.
It's rather difficult to test this code in an automated fashion, even if you have access to a physical DVD 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, some 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 "difficult" 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 DVD 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. | |
Initializes the writer's associated ISO image. | |
Adds a filepath entry to the writer's associated ISO image. | |
Writes an ISO image to the media in the device. | |
Resets (overrides) the newDisc flag on the internal image. | |
Gets the estimated size of the image associated with the writer. | |
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 (saved for reference only). | |
hardwareId : Hardware id for this writer (always the device path). | |
driveSpeed : Speed at which the drive writes. | |
media : Definition of media that is expected to be in the device. | |
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=None,
driveSpeed=None,
mediaType=2,
noEject=False,
unittest=False)
|
isRewritable(self)Indicates whether the media is rewritable per configuration. |
retrieveCapacity(self, entireDisc=False)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. The same will happen if the disc can't be read for some
reason. Otherwise, the capacity will be calculated by subtracting the
sectors currently used on the disc, as reported by
growisofs itself.
|
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.
|
initializeImage(self, newDisc, tmpdir, mediaLabel=None)Initializes the writer's associated ISO image. This method initializes theimage instance variable so
that the caller can use the addImageEntry method. Once
entries have been added, the writeImage method can be
called with no arguments.
|
addImageEntry(self, path, graftPoint)Adds a filepath entry to the writer's associated ISO image. The contents of the filepath -- but not the path itself -- will be added to the image at the indicated graft point. If you don't want to use a graft point, just passNone .
|
writeImage(self, imagePath=None, newDisc=False, writeMulti=True)Writes an ISO image to the media in the device. If If writeMulti argument is ignored. It exists for
compatibility with the Cedar Backup image writer interface.
|
setImageNewDisc(self, newDisc)Resets (overrides) the newDisc flag on the internal image.
|
getEstimatedImageSize(self)Gets the estimated size of the image associated with the writer. This is an estimate and is conservative. The actual image could be as much as 450 blocks (sectors) smaller under some circmstances.
|
Property Details |
---|
deviceFilesystem device name for this writer. |
scsiIdSCSI id for the device (saved for reference only). |
hardwareIdHardware id for this writer (always the device path). |
driveSpeedSpeed at which the drive writes. |
mediaDefinition of media that is expected to be in the device. |
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 Thu Mar 29 20:58:25 2007 | http://epydoc.sf.net |