def run(self): """ Start processing. """ while True: # Get a new task from queue. task = self.tasks.get() logger.debug("Processing task %s" % task.id) task.state = "P" task.save() try: results = {} for module in self.modules: current = module() current.data = results output = current.run(task) if isinstance(output, AutoVivification): results.update(output) else: logger.warning( "Module %s returned results not in dict format." % module) print results # Complete. task.analysis_id = save_results(results) task.state = "C" logger.info("Processed task {0} with success".format(task.id)) except Exception, e: logger.exception("Error processing task {0}: {1}".format( task.id, e)) task.state = "F" finally:
def process_image(self, task): """Process an image. @param task: image task """ try: results = {} # Save reference to image data on GridFS. results["file_data"] = task.image_id for module in self.modules: try: results = self.run_module(task, module, results) except GhiroPluginException: continue # Complete. task.analysis_id = save_results(results) task.state = "C" logger.info("[Task {0}]: Processed task with success".format(task.id)) except Exception as e: logger.exception("[Task {0}]: Critical error processing, skipping task: {1}".format(task.id, e)) task.state = "F" finally: # Saving timestamp. task.completed_at = now() # Save. task.save() self.tasks.task_done()
def run(self): """ Start processing. """ while True: # Get a new task from queue. task = self.tasks.get() logger.debug("Processing task %s" % task.id) task.state = "P" task.save() try: results = {} for module in self.modules: current = module() current.data = results output = current.run(task) if isinstance(output, AutoVivification): results.update(output) else: logger.warning("Module %s returned results not in dict format." % module) print results # Complete. task.analysis_id = save_results(results) task.state = "C" logger.info("Processed task {0} with success".format(task.id)) except Exception, e: logger.exception("Error processing task {0}: {1}".format(task.id, e)) task.state = "F" finally:
def _process_image(self, task): """Process an image. @param task: image task """ try: results = {} # Save reference to image data on GridFS. results["file_data"] = task.image_id for module in self.modules: current = module() current.data = results try: output = current.run(task) except Exception as e: logger.exception("Critical error in plugin {0}, skipping: {1}".format(module, e)) continue else: if isinstance(output, AutoVivification): results.update(output) else: logger.warning("Module %s returned results not in dict format." % module) # Complete. task.analysis_id = save_results(results) task.state = "C" logger.info("Processed task {0} with success".format(task.id)) except Exception, e: logger.exception("Critical error processing task {0}, skipping task: {1}".format(task.id, e)) task.state = "F"
def _process_image(self, task): """Process an image. @param task: image task """ try: results = {} # Save reference to image data on GridFS. results["file_data"] = task.image_id for module in self.modules: current = module() current.data = results try: output = current.run(task) except Exception as e: logger.exception( "Critical error in plugin {0}, skipping: {1}".format( module, e)) continue else: if isinstance(output, AutoVivification): results.update(output) else: logger.warning( "Module %s returned results not in dict format." % module) # Complete. task.analysis_id = save_results(results) task.state = "C" logger.info("Processed task {0} with success".format(task.id)) except Exception, e: logger.exception( "Critical error processing task {0}, skipping task: {1}". format(task.id, e)) task.state = "F"