Exemple #1
0
    def get_errors(keys):
        out = {}
        err = {}
        retry = 0
        while keys and retry < max_retry:
            if retry:
                time.sleep(2 ** (retry - 7))
            err.update(STORAGE.get_errors_dict(keys))
            keys = [x for x in err_keys if x not in err]
            retry += 1

        out["errors"] = err
        out["missing_error_keys"] = keys

        return out
Exemple #2
0
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)