def get_file_infos(keys): infos = {} retry = 0 while keys and retry < max_retry: if retry: time.sleep(2 ** (retry - 7)) infos.update(STORAGE.get_files_dict(keys)) keys = [x for x in keys if x not in infos] retry += 1 return infos
def get_multiple_service_keys(**kwargs): """ Get multiple result and error keys at the same time Variables: None Arguments: None Data Block: {"error": [], #List of error keys to lookup "result": [] #List of result keys to lookup } Result example: {"error": {}, #Dictionary of error object matching the keys "result": {} #Dictionary of result object matching the keys } """ user = kwargs['user'] data = request.json errors = STORAGE.get_errors_dict(data['error']) results = STORAGE.get_results_dict(data['result']) srls = list(set([x[:64] for x in results.keys()])) file_infos = STORAGE.get_files_dict(srls) for r_key in results.keys(): r_value = format_result(user['classification'], results[r_key], file_infos[r_key[:64]]['classification']) if not r_value: del results[r_key] else: results[r_key] = r_value out = {"error": errors, "result": results} return make_api_response(out)