Пример #1
0
    def worker_exists(worker_id):
        """
        Check if a worker 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)
        return database.exists(WORKER_HEADER + worker_id)
Пример #2
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)))