UDisks: DeviceJobChanged and testing
Rory Yorke
rory.yorke at gmail.com
Fri May 27 23:35:33 PDT 2011
Hi,
I'm using UDisks (via Python and DBus) to launch a program after a disk has
been mounted. I'm not sure which signal to listen for, but DeviceJobChanged
looks like it might be the right one.
On my Ubuntu 10.04 system with udisks 1.0.1-1ubuntu1, if I listen for
this signal and print out the arguments, and plug in a USB drive (see
code at end), I get this:
/org/freedesktop/UDisks/devices/sdd1 1 'FilesystemMount' 1000 0 -1.0
/org/freedesktop/UDisks/devices/sdd1 0 '' 0 0 -1.0
It seems to me that the job id ('FilesystemMount') should appear in the second
signal received; my guess is that in device.c job_complete(), if the
deallocation (block containing g_free(job->device->priv->job_i);) came after
the emit_job_changed() call, then that's what would happen.
I would try this, but I couldn't see any testing of any signals in tests/run,
and, regardless, I get many failures running that test suite. Should I kill
my system udisks-daemon before running the tests, or run it in a udisk-less
virtual machine, or should it Just Work? I've installed mdadm and LVM (and
possibly other things asked for by the test suite), but even something like
"sudo tests/run FS.test_ext3" fails with "AssertionError: mount point was not
removed".
Incidentally, the documented arguments for DeviceJobChanged are wrong.
Regards,
Rory
------------------------------------------------------------------------
def handler(object_path, job_in_progress, job_id,
job_initiated_by_uid, job_is_cancellable, job_percentage):
print object_path,job_in_progress,repr(str(job_id)),job_initiated_by_uid,
print job_is_cancellable,job_percentage
if __name__=='__main__':
import gobject
import dbus
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
bus= dbus.SystemBus()
bus.add_signal_receiver(handler,
'DeviceJobChanged',
'org.freedesktop.UDisks',
'org.freedesktop.UDisks',
'/org/freedesktop/UDisks')
gobject.MainLoop().run()
More information about the devkit-devel
mailing list