Exemple #1
0
def get_partial(identifier):
    """ Function to return a generated partial """
    if not cache.exists('partial', identifier):
        resp = flask.Response(
            json.dumps({
                "result":
                "Partial with identifier %s not found" % identifier,
            }),
            status=404,
        )
        return resp

    if cache.is_blank_file('partial', identifier):
        log.debug('Record found, status: IN PROGRESS')
        resp = flask.Response(json.dumps({"result": "wait"}), status=202)
    else:
        log.debug('Record found, status: COMPLETED')
        if flask.request.method == 'HEAD':
            url = flask.url_for('get_partial', identifier=identifier)
            resp = flask.Response(json.dumps({"result": url}),
                                  status=200,
                                  mimetype='application/json')
        else:
            resp = cache.retrieve_or_redirect('partial', identifier)

    return resp
Exemple #2
0
def get_patch(sha_from, sha_to):
    """ Function to return a patch from cache """
    identifier = _get_identifier(sha_from, sha_to)

    log.debug('Looking up record with identifier %s', identifier)
    if not cache.exists('patch', identifier):
        log.info('Invalid partial request')
        resp = flask.Response(
            json.dumps(
                {"result": "Patch with identifier %s not found" % identifier}),
            status=404,
        )
        return resp

    log.info('Patch found, retrieving ...')
    return cache.retrieve_or_redirect('patch', identifier)
Exemple #3
0
def get_patch(sha_from, sha_to):
    """ Function to return a patch from cache """
    identifier = _get_identifier(sha_from, sha_to)

    log.debug('Looking up record with identifier %s', identifier)
    if not cache.exists('patch', identifier):
        log.info('Invalid partial request')
        resp = flask.Response(
            json.dumps({
                "result": "Patch with identifier %s not found" % identifier
            }),
            status=404,
        )
        return resp

    log.info('Patch found, retrieving ...')
    return cache.retrieve_or_redirect('patch', identifier)
Exemple #4
0
def get_partial(identifier):
    """ Function to return a generated partial """
    if not cache.exists('partial', identifier):
        resp = flask.Response(
            json.dumps({
                "result": "Partial with identifier %s not found" % identifier,
            }),
            status=404,
        )
        return resp

    if cache.is_blank_file('partial', identifier):
        log.debug('Record found, status: IN PROGRESS')
        resp = flask.Response(json.dumps({"result": "wait"}), status=202)
    else:
        log.debug('Record found, status: COMPLETED')
        if flask.request.method == 'HEAD':
            url = flask.url_for('get_partial', identifier=identifier)
            resp = flask.Response(json.dumps({"result": url}), status=200,
                                  mimetype='application/json')
        else:
            resp = cache.retrieve_or_redirect('partial', identifier)

    return resp