1
2
3
4 """
5 Hardware monitoring classes based on linux' HAL system.
6 """
7
8 import os
9 import dbus
10 import glob
11
12 from twisted.application import service
13 from twisted.internet import reactor
14
15
16 DBUS_INTERFACE = "org.freedesktop.DBus"
17 HAL_INTERFACE = 'org.freedesktop.Hal'
18 HAL_DEVICE_INTERFACE = 'org.freedesktop.Hal.Device'
19 HAL_MANAGER_INTERFACE = 'org.freedesktop.Hal.Manager'
20 HAL_MANAGER_UDI = '/org/freedesktop/Hal/Manager'
21
22
23
24
25 HAL_SUBSYSTEM_PROPERTIES = {
26 'serial': ['originating_device', 'device', 'port', 'type'],
27 'video4linux': ['device', 'version'],
28 'input': ['device']
29 }
30
31
33 """
34 A generic hardware monitor class based on HAL. Listens for device add/remove filtered on a specific subsystem.
35
36 @ivar subsystem: The HAL subsystem type to monitor. E.g. serial, video4linux, ...
37 @ivar deviceInfo: dict which will be filled with device information. Key is the HAL UDI (Unique Device Identifier).
38 @ivar uniquePath: If set, point to a directory where the symlinks to the unique devices will be made, e.g. /dev/serial/by-id/
39 @ivar events: If set, point to a L{sparked.events.EventDispatcher} to dispatch <subsystem>-{added,removed} events to.
40 """
41
42 subsystem = None
43 deviceInfo = None
44 uniquePath = None
45 events = None
46
47
62
63
68
69
71 obj = self.bus.get_object(HAL_INTERFACE, udi)
72 return dbus.Interface(obj, interface)
73
74
103
104
115
116
118 """
119 This method will be called when a device has been added. If
120 you subclass this class, this method can be overruled to do
121 application-specific stuff.
122 """
123
124
126 """
127 This method will be called when a device has been removed. If
128 you subclass this class, this method can be overruled to do
129 application-specific stuff.
130 """
131