#NEWLINE# @ classmethod #NEWLINE# def classify( cls , queue , classifiers , error , threshold ) : #NEWLINE# #INDENT# "Determine which category, if any, a signature belongs to.\n\n        If it doesn't find a match, then it'll save the error into a new\n        category, which subsequent errors are checked against.\n\n        Args:\n            queue: redis connection instance.\n            classifiers: list of Classifier instances.\n            error: dict of json payload with a 'sig' key.\n            threshold: float, classification threshold to match.\n        " #NEWLINE# categories = cls . get_all_categories ( queue ) #NEWLINE# matched_cat = None #NEWLINE# start = time . time ( ) #NEWLINE# for classifier in classifiers : #NEWLINE# #INDENT# matched = False #NEWLINE# for cat in categories : #NEWLINE# #INDENT# if classifier . check_message ( cat , error , threshold ) : #NEWLINE# #INDENT# cat . events . add_event ( error ) #NEWLINE# matched_cat = cat #NEWLINE# matched = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if matched : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# cat_sig = error [ 'sig' ] #NEWLINE# matched_cat = cls . create ( queue , cat_sig , event = error ) #NEWLINE# #UNINDENT# end = time . time ( ) #NEWLINE# log . info ( ( 'Classification took %.2f seconds for matched category %s' % ( ( end - start ) , matched_cat . cat_id ) ) ) #NEWLINE# return matched_cat