def load(operation_id, logger=None): redis = RedisConnector() redis_key = OperationStatus._get_key(operation_id) if redis.exists(redis_key): attributes_json = redis.get(redis_key) attributes = json.loads(attributes_json.decode('UTF-8')) operation = OperationStatus() operation.set_attributes(attributes) return operation else: if logger is not None: logger.error("Operation with %s not found" % operation_id) raise Exception("Operation with %s not found" % operation_id)
def save(self): redis = RedisConnector() self.updated_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S") redis.set(self._get_key(self.id), json.dumps(self.as_dict(), ensure_ascii=False))