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 _device_select(devices, callback, splash): last_device_udi = config.get_last_device() if last_device_udi and len(devices) == 1: # if theres a saved last_device_udi and there's only one # device (otherwise user has to select one) and udis # match, skip the device selection dialog def serialized_udi_cb(udi): if udi == last_device_udi: callback(devices[0]) return _ask_user_for_device(devices, callback, splash) d = devices[0].get_serialized_udi() d.addCallback(serialized_udi_cb) return # either there's no last_device_udi (first time) or there's # more than one device on the system and user needs to select _ask_user_for_device(devices, callback, splash)