def identify_dev_cb(model): self.device = device DeviceProfileCache.store(device) config.set_last_device(device.cached_id) hook_it_up(self.splash, DeviceListener(self.device), self.device)
def process_device_added(): properties = self.get_devices_properties() cached_id = None for device in DeviceProfileCache.get_cached_devices(): if device in properties: cached_id = device.cached_id for plugin in PluginManager.get_plugins(IDBusDevicePlugin): if plugin in properties: try: plugin.setup(properties) if cached_id: plugin.cached_id = cached_id if (plugin.udi in self.udi_device): continue self.udi_device[str(plugin.udi)] = plugin d = DeviceResolver.identify_device(plugin) def select_and_configure(name): try: plugin = \ PluginManager.get_plugin_by_remote_name(name) plugin.setup(properties) self.udi_device[str(plugin.udi)] = plugin self.device_list.append(plugin) self.view.device_added(plugin) except Exception, e: print e d.addCallback(select_and_configure) except Exception, e: pass
def _device_select(devices, callback, splash): try: last_device_id = config.get_last_device() device = DeviceProfileCache.load(last_device_id) #If device is a DBus device, it has to have been detected to be #used. if (isinstance(device, DBusDevicePlugin) and not device in devices): _ask_user_for_device(devices, callback, splash) else: callback(device) except IOError: _ask_user_for_device(devices, callback, splash)
def _ask_user_for_device(devices, callback, splash): cached_devices = DeviceProfileCache.get_cached_devices() for cached_device in list(cached_devices): if isinstance(cached_device, DBusDevicePlugin) \ and not cached_device in devices: cached_devices.remove(cached_device) all_devices = cached_devices + [device for device in devices if device not in cached_devices] controller = DeviceSelectionController(Model(), all_devices, callback, splash) view = DeviceSelectionView(controller) view.show()
def _ask_user_for_device(devices, callback, splash): cached_devices = DeviceProfileCache.get_cached_devices() for cached_device in list(cached_devices): if isinstance(cached_device, DBusDevicePlugin) \ and not cached_device in devices: cached_devices.remove(cached_device) all_devices = cached_devices + [ device for device in devices if device not in cached_devices ] controller = DeviceSelectionController(Model(), all_devices, callback, splash) view = DeviceSelectionView(controller) view.show()