def loadApilst(self): """ API列表预加载,解析api_conf.json配置文件并将api列表加载到内存 return api confs list when success otherwise a small then 0 int error code instead -- error code ---- -1:Unable to load api configuations ---- -2:Configuations result format error """ #获取Api配置 api_confs = json.loads(confmanage.load_xml_api_confs(self.__apiPath)) # print 'api_confs => ', api_confs if api_confs.get('errnum') == 0: if 'data' in api_confs: #结果集完好,读取api_list rst_val = api_confs.get('data') api_list = {} for api in rst_val: #过滤从配置文件中获取的api配置列表,如果在配置文件中load=False的话,不会对Api进行加载 if api.get('load', True) == 'True' or api.get( 'load', True) == True: api.get('resources', {}).get('url', '') api_list.update({ api.get('resources', {}).get('url', ''): self.getHandler(api) }) rst_val = api_list else: rst_val = -2 else: rst_val = -1 return rst_val
def loadApilst(self): """ API列表预加载,解析api_conf.json配置文件并将api列表加载到内存 return api confs list when success otherwise a small then 0 int error code instead -- error code ---- -1:Unable to load api configuations ---- -2:Configuations result format error """ #获取Api配置 api_confs = json.loads(confmanage.load_xml_api_confs(self.__apiPath)) # print 'api_confs => ', api_confs if api_confs.get('errnum') == 0 : if 'data' in api_confs : #结果集完好,读取api_list rst_val = api_confs.get('data') api_list = {} for api in rst_val: #过滤从配置文件中获取的api配置列表,如果在配置文件中load=False的话,不会对Api进行加载 if api.get('load', True) == 'True' or api.get('load', True) == True: api.get('resources', {}).get('url', '') api_list.update({api.get('resources', {}).get('url', ''):self.getHandler(api)}) rst_val = api_list else : rst_val = -2 else : rst_val = -1 return rst_val
def preload_apilst(self): """API列表预加载,解析api_conf.json配置文件并将api列表加载到内存""" GLOBAL.LOGGER.logInfo("Preloading api list...") api_lst = confmanage.load_xml_api_confs(self.__apiPath) if api_lst.get('error') == 0 : if 'data' in api_lst : #结果集完好,读取api_list api_lst = api_lst.get('data') else : GLOBAL.LOGGER.logError("Configuations result format error") api_lst = None else : GLOBAL.LOGGER.logError("Unable to load api configuations ErrorCode:%s ErrorMessage:'%s'" % (api_lst['error'], api_lst['msg'])) api_lst = None return api_lst