Example #1
0
    def worker_delete(worker_id):
        """
        Delete a worker if it exists

        :param worker_id: id of the worker to check
        :type worker_id: str
        :returns: True or False
        :rtype: bool
        """
        database = Database(DB_HOST, DB_PORT)
        try:
            if database.exists(WORKER_HEADER + worker_id):
                database.delete(WORKER_HEADER + worker_id)
        except Exception as e:
            manager_logger.error("Unable to delete worker '{}': {}".format(
                worker_id, str(e)))
Example #2
0
    def submit(self, AMT):
        """
        Submit self through the AMT connection and update self with the results
        :param AMT: The open AMT connection object
        :return:
        """
        response = AMT.push(self)
        database = Database(DB_HOST, DB_PORT)
        database.delete(HIT_HEADER + self.opencrowd_id)
        for key in response['HIT']:
            setattr(self, key, (response['HIT'][key]))

        setattr(self, 'CreationTime', str(self.CreationTime))
        setattr(self, 'Expiration', str(self.Expiration))
        setattr(self, 'opencrowd_id', str(self.HITId))
        setattr(self, 'HITId', str(self.HITId))
        self.save()
        return self
Example #3
0
 def recursive_delete(self):
     """
     Delete all instances, via ids, tracked on this instance
     """
     project_ids = self.list_project_ids()
     task_ids = self.list_task_ids()
     HIT_ids = self.list_HIT_ids()
     assignment_ids = self.list_assignment_ids()
     question_ids = self.list_question_ids()
     database = Database(DB_HOST, DB_PORT)
     for question_id in question_ids:
         database.delete(QUESTION_HEADER + question_id)
     for assignment_id in assignment_ids:
         database.delete(ASSIGNMENT_HEADER + assignment_id)
     for HIT_id in HIT_ids:
         database.delete(HIT_HEADER + HIT_id)
     for task_id in task_ids:
         database.delete(TASK_HEADER + task_id)
     for project_id in project_ids:
         database.delete(PROJECT_HEADER + project_id)
     self.project_ids = []
     self.save()