simple dbus python problem ... please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bob

    #1

    simple dbus python problem ... please help

    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.

    The error is:

    Traceback (most recent call last):
    File "./dbus-3.py", line 6, in ?
    hal_service = bus.get_service ('org.freedeskt op.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.freedeskt op.Hal')
    hal_manager = hal_service.get _object ('/org/freedesktop/Hal/Manager',
    'org.freedeskto p.Hal.Manager')

    volume_udi_list = hal_manager.Fin dDeviceByCapabi lity ('volume')
    for udi in volume_udi_list :
    volume = hal_service.get _object (udi, 'org.freedeskto p.Hal.Device')
    device_file = volume.GetPrope rty ('block.device' )
    fstype = volume.GetPrope rty ('volume.fstype ')
    storage_udi = volume.GetPrope rty ('block.storage _device')
    storage = hal_service.get _object (storage_udi, 'org.freedeskto p.Hal.Device')
    drive_type = storage.GetProp erty ('storage.drive _type')
    print 'udi=%s device_file=%s fstype=%s drive_type=%s'% (udi,
    device_file, fstype, drive_type)

    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!

    All I really want to do is have a nice routine to do the following:

    1. check whether or not a user has a dvd drive.
    2. check whether a disc is in it.
    3. if there is a disc in the drive, check the various properties relating
    to it.

    Surely it cannot be that hard to get enough information to work out how to
    do that!

    Thanks for reading :)
  • alisonken1

    #2
    Re: simple dbus python problem ... please help


    bob wrote:

    <snip>
    bus = dbus.Bus (dbus.Bus.TYPE_ SYSTEM)
    hal_service = bus.get_service ('org.freedeskt op.Hal')
    hal_manager = hal_service.get _object ('/org/freedesktop/Hal/Manager',
    'org.freedeskto p.Hal.Manager')
    >
    <snip>

    It appears that bus.get_service () has been deprecated and deleted.

    Not sure about the changes, so anyone else who can help please jump in.

    Comment

    Working...