3
from gi.repository import GUdev
4
from gi.repository import GLib
6
from usbcreator.backends.base import Backend
7
from usbcreator import misc
10
'ID_VENDOR_ID': ('18d1',),
11
'ID_MODEL_ID': ('4e40', 'd001',),
14
class FastbootBackend(Backend):
16
Backend.__init__(self)
17
logging.debug('FastbootBackend')
18
self.client = GUdev.Client(subsystems=['usb'])
20
def on_uevent(self, action, device):
21
logging.debug('action: %s' % action)
22
logging.debug('device: %s' % device.get_sysfs_path())
24
for key,ids in KNOWN_IDS.items():
25
result = device.get_property(key)
27
logging.debug('Unknown %s: %s' % (key, result))
30
[logging.debug('%s=%s' % (k, device.get_property(k))) for k in device.get_property_keys()]
32
key = device.get_property('ID_SERIAL_SHORT')
36
'vendor' : device.get_property('ID_VENDOR_FROM_DATABASE'),
37
'model' : device.get_property('ID_MODEL'),
39
'device' : device.get_property('ID_SERIAL_SHORT'),
40
'status' : misc.CAN_USE,
42
if misc.callable(self.target_added_cb):
43
self.target_added_cb(key)
44
elif action == 'remove':
45
self._device_removed(key)
47
def detect_devices(self):
48
def _on_uevent(client, action, device):
49
self.on_uevent(action, device)
51
self.client.connect('uevent', _on_uevent)
52
# Just in case, go over already attached devices
53
for device in self.client.query_by_subsystem('usb'):
54
self.on_uevent('add', device)
56
def update_free(self):
60
def _is_casper_cd(self, filename):