def __init__(self, *args, **kwargs): super(ServerStatus, self).__init__(self, *args, **kwargs) self.all_keys = dict(redis_string=['current_status', 'now_building', 'container', 'github_token', 'gitlab_token', 'building_start', 'building_num', 'docker_user', 'docker_password', 'gpg_key', 'gpg_password'], redis_string_bool=['status', 'idle', 'iso_flag', 'iso_building', 'iso_minimal'], redis_string_int=['building_num'], redis_list=['completed', 'failed', 'queue', 'pending_review', 'all_tl_events'], redis_zset=['all_packages']) if '' == getattr(self, 'status', ''): key_lists = ['redis_string', 'redis_string_bool', 'redis_string_int', 'redis_list', 'redis_zset'] for key_list_name in key_lists: key_list = self.all_keys[key_list_name] for key in key_list: if key_list_name.endswith('string'): setattr(self, key, '') elif key_list_name.endswith('bool'): setattr(self, key, False) elif key_list_name.endswith('int'): setattr(self, key, 0) elif key_list_name.endswith('list'): setattr(self, key, RedisList.as_child(self, key, str)) elif key_list_name.endswith('zset'): setattr(self, key, RedisZSet.as_child(self, key, str)) self.status = True self.current_status = 'Idle' self.idle = True self.now_building = 'Idle' self.iso_flag = False self.iso_building = False
def __init__(self, *args, **kwargs): super(ServerStatus, self).__init__(self, *args, **kwargs) self.namespace = 'antbs:status:' self.prefix = self.namespace[:-1] self.key_lists = dict(redis_string=['current_status', 'now_building', 'container', 'github_token', 'gitlab_token', 'building_start', 'building_num', 'docker_user', 'docker_password', 'gpg_key', 'gpg_password'], redis_string_bool=['status', 'idle', 'iso_flag', 'iso_building', 'iso_minimal'], redis_string_int=['building_num'], redis_list=['completed', 'failed', 'queue', 'pending_review', 'all_tl_events', 'hook_queue'], redis_zset=['all_packages']) self.all_keys = [item for sublist in self.key_lists.values() for item in sublist] if not self: for key in self.all_keys: if key in self.key_lists['redis_string']: setattr(self, key, '') elif key in self.key_lists['redis_string_bool']: setattr(self, key, False) elif key in self.key_lists['redis_string_int']: setattr(self, key, 0) elif key in self.key_lists['redis_list']: setattr(self, key, RedisList.as_child(self, key, str)) elif key in self.key_lists['redis_zset']: setattr(self, key, RedisZSet.as_child(self, key, str)) self.status = True self.current_status = 'Idle' self.idle = True self.now_building = 'Idle' self.iso_flag = False self.iso_building = False