~arsen/vengor

4edca9b72057fbafe2f15707777315feec940ba0 — Arsen Arsenović 2 years ago 95e388c
slightly improve UI for proxy errors
1 files changed, 11 insertions(+), 4 deletions(-)

M vengor/__init__.py
M vengor/__init__.py => vengor/__init__.py +11 -4
@@ 21,9 21,10 @@ import requests
import structlog
import structlog.processors
import structlog.stdlib
from flask import (Flask, redirect, render_template, request, safe_join,
                   send_file, url_for)
from werkzeug.exceptions import BadRequest, NotFound, PreconditionFailed
from flask import (Flask, Response, redirect, render_template, request,
                   safe_join, send_file, url_for)
from werkzeug.exceptions import (BadRequest, InternalServerError, NotFound,
                                 PreconditionFailed)

from . import tasks, utils
from .external.accept import accepts_query


@@ 106,6 107,12 @@ def request_common(modpath, modcache):
            # version doesn't exist, resolve it based on the .info
            log.info("proxy.remote_resolve")
            with requests.get(f"{proxy}/{name}/@v/{version}.info") as ireq:
                if ireq.status_code < 200 or ireq.status_code > 299:
                    error = b"got bad response from proxy: " + ireq.content + b"\n"
                    return Response(error,
                                    mimetype="text/plain",
                                    status=req.status_code)

                try:
                    info = ireq.json()
                    version = info["Version"]


@@ 120,7 127,7 @@ def request_common(modpath, modcache):
                except Exception:
                    # this version cannot be resolved at all
                    log.exception("proxy.resolve_failed")
                    raise NotFound()
                    raise InternalServerError()

    result = tasks.generate_result(prefix, name, version,
                                   make_modcache=modcache,