simple dbus & python query.
dennis
dbus at nomoreheroes.org.uk
Mon Jul 31 10:26:07 PDT 2006
Hi John,
Thanks a lot for that! That example is in the newest cvs download of the
source code by the way.
Is anyone active on this list who is able to modify that example in the
source-code package ? I think it needs to be updated to reflect those
changes. It'll prevent more people experiencing the frustration I have
had. I almost chickened out of solving this problem to do all the other
parts of my program, and even contemplated removing the part involving
dbus from my plans.
The only reason I didn't (apart from wanting to get good enough to work
for redhat/ubuntu/google or similar asap) was because the program is a
simple GUI tool for burning (legally downloaded) movies to disc, one
that's so brain dead simple my g/f and dad are going to be able to use
it after a max 10mins explaination .. so it *has* to spot things they'll
forget like not putting a dvd in the drive, it's not a blank one etc. I
want a modified version of it to be the power behind a "burn movie to
disc" option when someone right-clicks on an avi/mpg/etc. That'd be sweet!
John (J5) Palmieri wrote:
> You are using the 0.2x API. The newer API looks like this:
>
> bus = dbus.SystemBus()
> hal_manager_obj = self.bus.get_object("org.freedesktop.Hal",
>
> "/org/freedesktop/Hal/Manager")
> hal_manager_iface = dbus.Interface(self.hal_manager_obj,
>
> "org.freedesktop.Hal.Manager")
>
>
> dennis wrote:
>> Hi,
>>
>> I have this sample python script from the hal sources, but it doesn't
>> work
>> for me. This is despite other example python scripts I have to help
>> me are
>> working fine. The problem is that this script is the closet to what
>> it is
>> I actually want to learn to do.
>>
>> My system: ubuntu 6.06 (inc. all updates) on a bog standard x86 P4 PC.
>>
>> I've been googling on this one, and tried newsgroups too, to no
>> avail. I'm a bit of a coding newbie, too, although I'm not totally
>> new to all the important & relevant concepts.
>>
>> Documentation on this stuff is extremely thin on the ground, so links to
>> any good resources other than those at freedesktop.org would be most
>> appreciated ... the "simpler" and easier to follow that they are the
>> better.
>>
>> For my current problem, the error is:
>>
>> Traceback (most recent call last):
>> File "./dbus-3.py", line 6, in ?
>> hal_service = bus.get_service ('org.freedesktop.Hal')
>> AttributeError: 'SystemBus' object has no attribute 'get_service'
>>
>>
>> The script is as follows:
>>
>> #!/usr/bin/python
>>
>> import dbus
>>
>> bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM)
>> hal_service = bus.get_service ('org.freedesktop.Hal')
>> hal_manager = hal_service.get_object ('/org/freedesktop/Hal/Manager',
>> 'org.freedesktop.Hal.Manager')
>>
>> volume_udi_list = hal_manager.FindDeviceByCapability ('volume')
>> for udi in volume_udi_list:
>> volume = hal_service.get_object (udi, 'org.freedesktop.Hal.Device')
>> device_file = volume.GetProperty ('block.device')
>> fstype = volume.GetProperty ('volume.fstype')
>> storage_udi = volume.GetProperty ('block.storage_device')
>> storage = hal_service.get_object (storage_udi,
>> 'org.freedesktop.Hal.Device')
>> drive_type = storage.GetProperty ('storage.drive_type')
>> print 'udi=%s device_file=%s fstype=%s drive_type=%s'%(udi,
>> device_file, fstype, drive_type)
>> _______________________________________________
>> dbus mailing list
>> dbus at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dbus
>
More information about the dbus
mailing list