Excerpts from Richard Shaw's message of Thu Oct 13 16:13:00 +0200 2011:
On Wed, Oct 12, 2011 at 8:16 PM, Dan Williams <dcbw(a)redhat.com>
wrote:
> udev replaced HAL, along with some additional helpers. udev has a
> database too, much like HAL. You can use libudev or libgudev (if you
> use glib) to talk to udev and get information.
Ok, I found python-gudev which lets me talk to udev!
And I thought the documentation on UDisks was poor. The only
documentation in the package is a README file with a bad link and a
test program.
You can use [1] (or look in your kernel source directory) for gudev
API documentation. The python wrapper basically does 1:1 copy of the
functions.
>> I've worked around that for testing the property
>> "DriveMediaCompatibility" > 0 since it returns an array but this
would
>> also pick up flash card readers, zip, and jaz drives. I'll have to
>> modify that to look for "optical" on the front of any members of the
>> array.
>>
>> Second, I can not find any property that reports the disc capacity.
>> The only property that looked close is "DriveSize" but for a blank
>> disc this reports the same as the SectorSize, 2048.
>
> UDISKS_PARTITION_SIZE
I'm thinking the equivalent in the python wrapper is "PartitionSize".
The problem is that it AND "DeviceSize" both report 2048...
There is still a possibility there is a bug (or a missing feature) in
udisks. Maybe have a look at udisks/udev bug tracker?
Right now I'm using the test program provided with python-gudev
and I
think I'm making headway. It has a property "ID_TYPE" that is
"cd" for
optical drives so that's one problem down. Now I just have to figure
out how to:
1. Get the drive capacity.
2. Get the media state.
3. Detect and properly handle media changes.
Good luck finding what you are looking for,
[1]
ftp://slackware.oregonstate.edu/pub/linux/utils/kernel/hotplug/gudev/inde...
--
Stanislav Ochotnicky <sochotnicky(a)redhat.com>
Software Engineer - Base Operating Systems Brno
PGP: 7B087241
Red Hat Inc.
http://cz.redhat.com