def detect(self, tuple):
     """
     Detect behaviors
     """
     try:
         if not self.dontdetect:
             (detected, label, statelen) = __markov_models__.detect(tuple, self.verbose)
             #(detected, label) = __markov_models__.detect(tuple, self.verbose)
             if detected:
                 # Change color
                 tuple.set_color(magenta)
                 # Set the detection label
                 tuple.set_detected_label(label)
                 """
                 # Set the detection state len
                 tuple.set_best_model_matching_len(statelen)
                 """
                 if self.verbose > 5:
                     print 'Last flow: Detected with {}'.format(label)
                 # Play sound
                 if args.sound:
                     pygame.mixer.music.play()
             elif not detected and self.only_detections:
                 # Not detected by any reason. No model matching but also the state len is too short.
                 tuple.unset_detected_label()
                 if self.verbose > 5:
                     print 'Last flow: Not detected'
                 tuple.dont_print()
     except Exception as inst:
         print '\tProblem with detect()'
         print type(inst)     # the exception instance
         print inst.args      # arguments stored in .args
         print inst           # __str__ allows args to printed directly
         sys.exit(1)
示例#2
0
 def detect(self, tuple):
     """
     Detect behaviors
     """
     try:
         if not self.dontdetect:
             (detected, label, statelen) = __markov_models__.detect(tuple, self.verbose)
             if detected:
                 # Change color
                 tuple.set_color(magenta)
                 # Set the detection label
                 tuple.set_detected_label(label)
                 """
                 # Set the detection state len
                 tuple.set_best_model_matching_len(statelen)
                 """
                 if self.verbose > 5:
                     logging.debug('Last flow: Detected with {}'.format(label))
                 return True
             elif not detected:
                 # Not detected by any reason. No model matching but also the state len is too short.
                 tuple.unset_detected_label()
                 if self.verbose > 5:
                     logging.debug('Last flow: Not detected')
                 tuple.dont_print()
                 return False
     except Exception as inst:
         logging.exception('\tProblem with detect()')
         logging.exception(type(inst))     # the exception instance
         logging.exception(inst.args)      # arguments stored in .args
         logging.exception(inst)           # __str__ allows args to printed directly
         sys.exit(1)
def detect(tuple):


    # #----------------------------------------
    # #----------- Real option -------------------
    # Analyze state a return name of the result.
    (detected, label, matching_len) = __markov_models__.detect(tuple, 50)
    return (detected, label, matching_len)
示例#4
0
 def detect(self, tuple):
     """
     Detect behaviors
     """
     if not self.dontdetect:
         detected = __markov_models__.detect(tuple, self.verbose)
         if detected:
             # Change color
             tuple.set_color(magenta)
             # Play sound
             if args.sound:
                 pygame.mixer.music.play()
         elif not detected and self.only_detections:
             tuple.dont_print()