#NEWLINE# def gather_device_info( ) : #NEWLINE# #INDENT# "This function is responsible for digging through the dbus bluetooth database and retrieving all the known\n\tdevices and the information about those devices. The database is seeded from scan_devices.\n\n\tReturns:\n\t\tList of device objects. Each object is one device and consisting of the properties of that device.\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\t'alias': 'Bluetooth Keyboard',\n\t\t\t\t\t'address': '00:00:00:00:00:00',\n\t\t\t\t\t'rssi': '-54',\n\t\t\t\t\t'icon': 'input-keyboard',\n\t\t\t\t\t'paired': 0,\n\t\t\t\t\t'connected': 0\n\t\t\t\t}\n\t\t\t]\n\t" #NEWLINE# devices = [ ] #NEWLINE# bus = dbus . SystemBus ( ) #NEWLINE# objects = get_managed_objects ( ) #NEWLINE# all_devices = ( str ( path ) for ( path , interfaces ) in objects . items ( ) if ( DEVICE_INTERFACE in interfaces ) ) #NEWLINE# for ( path , ifaces ) in objects . items ( ) : #NEWLINE# #INDENT# if ( ADAPTER_INTERFACE not in ifaces ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# device_list = [ d for d in all_devices if d . startswith ( ( path + '/' ) ) ] #NEWLINE# for dev_path in device_list : #NEWLINE# #INDENT# dev = objects [ dev_path ] #NEWLINE# properties = dev [ DEVICE_INTERFACE ] #NEWLINE# rssi = None #NEWLINE# icon = None #NEWLINE# if ( 'RSSI' in properties ) : #NEWLINE# #INDENT# rssi = int ( properties [ 'RSSI' ] ) #NEWLINE# #UNINDENT# if ( 'Icon' in properties ) : #NEWLINE# #INDENT# icon = str ( properties [ 'Icon' ] ) #NEWLINE# #UNINDENT# alias = properties [ 'Alias' ] #NEWLINE# address = properties [ 'Address' ] #NEWLINE# paired = properties [ 'Paired' ] #NEWLINE# connected = properties [ 'Connected' ] #NEWLINE# devices . append ( { #NEWLINE# #INDENT# 'alias' : str ( alias ) , #NEWLINE# 'address' : str ( address ) , #NEWLINE# 'rssi' : address , #NEWLINE# 'icon' : icon , #NEWLINE# 'paired' : int ( paired ) , #NEWLINE# 'connected' : int ( connected ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# return devices