#NEWLINE# def parse_message( self , message ) : #NEWLINE# #INDENT# '\n        Parse a single message arriving from the queue.  Updates list of open/closed urls.\n        :param message: A message from the queue\n        ' #NEWLINE# print ( message . body ) #NEWLINE# message = json . loads ( message . body ) #NEWLINE# url = message [ 'url' ] #NEWLINE# if ( message [ 'eventType' ] == 'START' ) : #NEWLINE# #INDENT# self . open_urls [ url ] = NutchUrlTrails . jtime_to_datetime ( message [ 'timestamp' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( message [ 'eventType' ] == 'END' ) : #NEWLINE# #INDENT# if ( url in self . open_urls ) : #NEWLINE# #INDENT# self . closed_urls [ url ] = ( self . open_urls [ url ] , NutchUrlTrails . jtime_to_datetime ( message [ 'timestamp' ] ) ) #NEWLINE# del self . open_urls [ message ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Unexpected message type' )