#NEWLINE# def scan_devices( self , previous , sync ) : #NEWLINE# #INDENT# device_info = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# updated_devices = self . rpc_callbacks . get_and_clear_updated_devices ( ) #NEWLINE# current_devices = self . mgr . get_all_devices ( ) #NEWLINE# device_info [ 'current' ] = current_devices #NEWLINE# if ( previous is None ) : #NEWLINE# #INDENT# previous = { #NEWLINE# #INDENT# 'added' : set ( ) , #NEWLINE# 'current' : set ( ) , #NEWLINE# 'updated' : set ( ) , #NEWLINE# 'removed' : set ( ) , #NEWLINE# 'timestamps' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# if self . prevent_arp_spoofing : #NEWLINE# #INDENT# self . mgr . delete_unreferenced_arp_protection ( current_devices ) #NEWLINE# #UNINDENT# #UNINDENT# device_info [ 'timestamps' ] = self . mgr . get_devices_modified_timestamps ( current_devices ) #NEWLINE# locally_updated = self . _get_devices_locally_modified ( device_info [ 'timestamps' ] , previous [ 'timestamps' ] ) #NEWLINE# if locally_updated : #NEWLINE# #INDENT# LOG . debug ( 'Adding locally changed devices to updated set: %s' , locally_updated ) #NEWLINE# updated_devices |= locally_updated #NEWLINE# #UNINDENT# if sync : #NEWLINE# #INDENT# device_info [ 'added' ] = current_devices #NEWLINE# device_info [ 'removed' ] = ( previous [ 'removed' ] | ( previous [ 'current' ] - current_devices ) ) #NEWLINE# device_info [ 'updated' ] = ( previous [ 'updated' ] | ( previous & current_devices ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# device_info [ 'added' ] = ( current_devices - previous [ 'current' ] ) #NEWLINE# device_info [ 'removed' ] = ( previous [ 'current' ] - current_devices ) #NEWLINE# device_info [ 'updated' ] = ( updated_devices & current_devices ) #NEWLINE# #UNINDENT# return device_info