#NEWLINE# def _arp( self ) : #NEWLINE# #INDENT# system = platform . system ( ) #NEWLINE# if ( system == 'Darwin' ) : #NEWLINE# #INDENT# process = subprocess . Popen ( [ 'arp' , '-a' ] , stdin = None , stdout = subprocess . PIPE , stderr = None , close_fds = True ) #NEWLINE# while True : #NEWLINE# #INDENT# line = process . stdout . readline ( ) #NEWLINE# if ( not line ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# match = MAC_RE . match ( line ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# logging . error ( 'Line not matched by regex: "%s"' , line . strip ( ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# mac = match . group ( 'mac' ) #NEWLINE# ip_address = match . group ( 'ip' ) #NEWLINE# state = ( 'INVALID' if ( mac == '(incomplete)' ) else 'REACHABLE' ) #NEWLINE# ( yield ( mac , ip_address , state ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( system == 'Linux' ) : #NEWLINE# #INDENT# process = subprocess . Popen ( [ 'ip' , '-s' , 'neighbor' , 'list' ] , stdin = None , stdout = subprocess . PIPE , stderr = None , close_fds = True ) #NEWLINE# while True : #NEWLINE# #INDENT# line = process . stdout . readline ( ) #NEWLINE# if ( not line ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# match = LINUX_RE . match ( line ) #NEWLINE# if ( not match ) : #NEWLINE# #INDENT# logging . error ( 'Line not matched by regex: "%s"' , line . strip ( ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# mac = match . group ( 'mac' ) #NEWLINE# ip_address = match . group ( 'ip' ) #NEWLINE# state = match . group ( 'state' ) #NEWLINE# ( yield ( mac , ip_address , state ) )