예제 #1
0
def update_analysis_results(task):
    """
    Update analysis results for this task.
    """

    # If the task does not currently exist for the given sample in the
    # database, add it.

    obj_class = class_from_type(task.obj._meta['crits_type'])

    obj = obj_class.objects(id=task.obj.id).first()
    obj_id = obj.id
    found = False
    for a in obj.analysis:
        if str(a.analysis_id) == task.task_id:
            found = True
            break

    if not found:
        logger.warning("Tried to update a task that didn't exist.")
        insert_analysis_results(task)
    else:
        # Otherwise, update it.
        ear = EmbeddedAnalysisResult()
        tdict = task.to_dict()
        tdict['analysis_id'] = tdict['id']
        del tdict['id']
        ear.merge(arg_dict=tdict)
        obj_class.objects(id=obj_id,
                          analysis__id=task.task_id).update_one(set__analysis__S=ear)
예제 #2
0
def insert_analysis_results(task):
    """
    Insert analysis results for this task.
    """

    obj_class = class_from_type(task.obj._meta['crits_type'])

    ear = EmbeddedAnalysisResult()
    tdict = task.to_dict()
    tdict['analysis_id'] = tdict['id']
    del tdict['id']
    ear.merge(arg_dict=tdict)
    obj_class.objects(id=task.obj.id).update_one(push__analysis=ear)
예제 #3
0
파일: db.py 프로젝트: brentonchang/crits-1
    def _insert_analysis_results(self, task):
        """
        Insert analysis results for this task.
        """

        obj_class = class_from_type(task.context.crits_type)
        query = self.get_db_query(task.context)

        ear = EmbeddedAnalysisResult()
        tdict = task.to_dict()
        tdict['analysis_type'] = tdict['type']
        tdict['analysis_id'] = tdict['id']
        del tdict['type']
        del tdict['id']
        ear.merge(arg_dict=tdict)
        ear.config = AnalysisConfig(**tdict['config'])
        obj_class.objects(__raw__=query).update_one(push__analysis=ear)
예제 #4
0
    def _insert_analysis_results(self, task):
        """
        Insert analysis results for this task.
        """

        obj_class = class_from_type(task.context.crits_type)
        query = self.get_db_query(task.context)

        ear = EmbeddedAnalysisResult()
        tdict = task.to_dict()
        tdict['analysis_type'] = tdict['type']
        tdict['analysis_id'] = tdict['id']
        del tdict['type']
        del tdict['id']
        ear.merge(arg_dict=tdict)
        ear.config = AnalysisConfig(**tdict['config'])
        obj_class.objects(__raw__=query).update_one(push__analysis=ear)
예제 #5
0
    def _update_analysis_results(self, task):
        """
        Update analysis results for this task.
        """

        # If the task does not currently exist for the given sample in the
        # database, add it.

        obj_class = class_from_type(task.context.crits_type)
        query = self.get_db_query(task.context)

        obj = obj_class.objects(__raw__=query).first()
        obj_id = obj.id
        found = False
        c = 0
        for a in obj.analysis:
            if str(a.analysis_id) == task.task_id:
                found = True
                break
            c += 1

        if not found:
            logger.warning("Tried to update a task that didn't exist.")
            self._insert_analysis_results(task)
        else:
            # Otherwise, update it.
            ear = EmbeddedAnalysisResult()
            tdict = task.to_dict()
            tdict['analysis_type'] = tdict['type']
            tdict['analysis_id'] = tdict['id']
            del tdict['type']
            del tdict['id']
            ear.merge(arg_dict=tdict)
            ear.config = AnalysisConfig(**tdict['config'])
            obj_class.objects(
                id=obj_id,
                analysis__id=task.task_id).update_one(set__analysis__S=ear)
예제 #6
0
파일: db.py 프로젝트: brentonchang/crits-1
    def _update_analysis_results(self, task):
        """
        Update analysis results for this task.
        """

        # If the task does not currently exist for the given sample in the
        # database, add it.

        obj_class = class_from_type(task.context.crits_type)
        query = self.get_db_query(task.context)

        obj = obj_class.objects(__raw__=query).first()
        obj_id = obj.id
        found = False
        c = 0
        for a in obj.analysis:
            if str(a.analysis_id) == task.task_id:
                found = True
                break
            c += 1

        if not found:
            logger.warning("Tried to update a task that didn't exist.")
            self._insert_analysis_results(task)
        else:
            # Otherwise, update it.
            ear = EmbeddedAnalysisResult()
            tdict = task.to_dict()
            tdict['analysis_type'] = tdict['type']
            tdict['analysis_id'] = tdict['id']
            del tdict['type']
            del tdict['id']
            ear.merge(arg_dict=tdict)
            ear.config = AnalysisConfig(**tdict['config'])
            obj_class.objects(id=obj_id,
                              analysis__id=task.task_id).update_one(set__analysis__S=ear)