summaryrefslogtreecommitdiff
path: root/examples/interface-locking-test.py
blob: 3b98cd1f6aab7730fc2c0a04421fa7562e649a1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python


import dbus
import time

# this example show how to prevent automounters from mounting volumes

bus = dbus.Bus(dbus.Bus.TYPE_SYSTEM)

manager = dbus.Interface(bus.get_object("org.freedesktop.Hal",
                                         "/org/freedesktop/Hal/Manager"),
                          "org.freedesktop.Hal.Manager")

# replace this with a volume on your system
device = dbus.Interface(bus.get_object("org.freedesktop.Hal",
                                         "/org/freedesktop/Hal/devices/volume_uuid_2232_1F11"),
                          "org.freedesktop.Hal.Device")

manager.AcquireGlobalInterfaceLock("org.freedesktop.Hal.Device.Storage", True)
#device.AcquireInterfaceLock("org.freedesktop.Hal.Device.Volume", True)
time.sleep(2)
manager.ReleaseGlobalInterfaceLock("org.freedesktop.Hal.Device.Storage")
#device.ReleaseInterfaceLock("org.freedesktop.Hal.Device.Volume")