示例#1
0
def judge():
    _token = request.headers.get("X-AOJ-Server-Token")
    submission_dir = uuid.uuid4().hex
    try:
        data = request.json
        data["submission_id"] = submission_dir
        result = JudgeServer.judge(**data)
        return {
            "success": True,
            "data": result,
            "user_output_path": submission_dir,
            "error": None
        }
    except (CompileError, TokenVerificationFailed, JudgeRuntimeError) as e:
        logger.exception(e)
        return {
            "success": False,
            "data": [],
            "error": e.__class__.__name__,
            "message": e.message,
            "user_output_path": submission_dir
        }
    except Exception as e:
        return {
            "success": False,
            "data": [],
            "error": e.__class__.__name__,
            "message": str(e),
            "user_output_path": submission_dir
        }
示例#2
0
def spawn_rconsole(*args):
    """
    USR2-activated debug console
    """
    try:
        from rfoo.utils import rconsole
    except ImportError:
        logger.exception("can't import rconsole - python-rfoo not installed?")
        return False
    try:
        rconsole.spawn_server(port=rconsole_port)
    except:
        logger.exception("Can't spawn rconsole!")
示例#3
0
 def decorated_function(*args, **kwargs):
     try:
         ensure_signinghub_machine_user_session()
         return f(*args, **kwargs)
     except AuthenticationException as ex:
         logger.exception("Authentication Error")
         return error(ex.error_description, code="digital-signing.signinghub.{}".format(ex.error_id))
     except NoQueryResultsException as ex:
         logger.exception("No Query Results Error")
         return error(ex.args[0])
     except BaseException as ex:
         logger.exception("Internal Server Error")
         return error("Internal Server Error", 500)
def handle_invalid_state(e):
    logger.exception(f"Invalid State: {e}")
    return error(f"Invalid State: {e}", 400)
def handle_resource_not_found(e):
    logger.exception(e.uri)
    return error(f"Not Found: {e.uri}", 404)