NolanGit / PersonalHomepage

使用Vue.js、Element UI作为前端,Python、Flask提供后端接口的一个前后端分离的导航页。Keywords:导航|主页|天气|书签|便签|翻译|苹果商店|App Store|价格监控|黄金|股票|基金|必应壁纸|热门新闻聚合|爬虫|网盘|图床|权限管理|短链接生成|异步脚本运行
Mozilla Public License 2.0
289 stars 66 forks source link

翻译 #24

Closed zhangrongwu closed 2 years ago

zhangrongwu commented 2 years ago

ValueError ValueError: from_language[en] or to_language[en] is not supported!

Traceback (most recent call last) File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2309, in call

def __call__(self, environ, start_response):
    """The WSGI server calls the Flask application object as the
    WSGI application. This calls :meth:`wsgi_app` which can be
    wrapped to applying middleware."""
    return self.wsgi_app(environ, start_response)

def __repr__(self):
    return '<%s %r>' % (
        self.__class__.__name__,
        self.name,

File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app try: ctx.push() response = self.full_dispatch_request() except Exception as e: error = e response = self.handle_exception(e) except: error = sys.exc_info()[1] raise return response(environ, start_response) finally: File "/usr/local/python3/lib/python3.6/site-packages/flask_cors/extension.py", line 165, in wrapped_function

Wrap exception handlers with cross_origin

    # These error handlers will still respect the behavior of the route
    if options.get('intercept_exceptions', True):
        def _after_request_decorator(f):
            def wrapped_function(*args, **kwargs):
                return cors_after_request(app.make_response(f(*args, **kwargs)))
            return wrapped_function

        if hasattr(app, 'handle_exception'):
            app.handle_exception = _after_request_decorator(
                app.handle_exception)

File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception

if we want to repropagate the exception, we can attempt to

        # raise it with the whole traceback in case we can do that
        # (the function was actually called from the except part)
        # otherwise, we just raise the error again
        if exc_value is e:
            reraise(exc_type, exc_value, tb)
        else:
            raise e

    self.log_exception((exc_type, exc_value, tb))
    if handler is None:

File "/usr/local/python3/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise from io import StringIO

def reraise(tp, value, tb=None):
    if value.__traceback__ is not tb:
        raise value.with_traceback(tb)
    raise value

implements_to_string = _identity

else: text_type = unicode File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app ctx = self.request_context(environ) error = None try: try: ctx.push() response = self.full_dispatch_request() except Exception as e: error = e response = self.handle_exception(e) except: error = sys.exc_info()[1] File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request request_started.send(self) rv = self.preprocess_request() if rv is None: rv = self.dispatch_request() except Exception as e: rv = self.handle_user_exception(e) return self.finalize_request(rv)

def finalize_request(self, rv, from_error_handler=False):
    """Given the return value from a view function this finalizes
    the request by converting it into a response and invoking the

File "/usr/local/python3/lib/python3.6/site-packages/flask_cors/extension.py", line 165, in wrapped_function

Wrap exception handlers with cross_origin

    # These error handlers will still respect the behavior of the route
    if options.get('intercept_exceptions', True):
        def _after_request_decorator(f):
            def wrapped_function(*args, **kwargs):
                return cors_after_request(app.make_response(f(*args, **kwargs)))
            return wrapped_function

        if hasattr(app, 'handle_exception'):
            app.handle_exception = _after_request_decorator(
                app.handle_exception)

File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception return self.handle_http_exception(e)

    handler = self._find_error_handler(e)

    if handler is None:
        reraise(exc_type, exc_value, tb)
    return handler(e)

def handle_exception(self, e):
    """Default exception handling that kicks in when an exception
    occurs that is not caught.  In debug mode the exception will

File "/usr/local/python3/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise from io import StringIO

def reraise(tp, value, tb=None):
    if value.__traceback__ is not tb:
        raise value.with_traceback(tb)
    raise value

implements_to_string = _identity

else: text_type = unicode File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request self.try_trigger_before_first_request_functions() try: request_started.send(self) rv = self.preprocess_request() if rv is None: rv = self.dispatch_request() except Exception as e: rv = self.handle_user_exception(e) return self.finalize_request(rv)

def finalize_request(self, rv, from_error_handler=False):

File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request

request came with the OPTIONS method, reply automatically

    if getattr(rule, 'provide_automatic_options', False) \
       and req.method == 'OPTIONS':
        return self.make_default_options_response()
    # otherwise dispatch to the handler for that endpoint
    return self.view_functions[rule.endpoint](**req.view_args)

def full_dispatch_request(self):
    """Dispatches the request and on top of that performs request
    pre and postprocessing as well as HTTP exception catching and
    error handling.

File "/www/python/PersonalHomepage/backend/app/limiter.py", line 20, in decorated_function if forbidden_user_agent.lower() in _current_ua.lower(): msg = ('褰撳墠User-Agent[%s]涓嶅厑璁歌闂�' % _current_ua) short_msg = 'User-Agent is forbidden' response = {'code': 401, 'msg': short_msg, 'message': msg} return jsonify(response), 401 return f(*args, **kwargs)

        return decorated_function

    return decorator

File "/usr/local/python3/lib/python3.6/site-packages/flask_limiter/extension.py", line 702, in inner self._auto_check and not g.get("_rate_limiting_complete") ): self.__check_request_limit(False) g._rate_limiting_complete = True return obj(*a, **k) return inner return _inner

def limit(
    self,

File "/www/python/PersonalHomepage/backend/app/privilege/privilege_control.py", line 80, in decorated_function return rsp.failed(short_msg), 403

        # 涓婅堪鏍¢獙鍧囬€氳繃锛屽埛鏂皍ser_key鐨勭敓鏁堟椂闂达紝骞剁户缁墽琛屼笟鍔¢€昏緫
        pf.get_redis_conn0().set(user_key, user_id, LOGIN_STATUS_EXPIRE_TIME)

        return f(*args, **kwargs)

    return decorated_function

return decorator

File "/www/python/PersonalHomepage/backend/app/translator/api.py", line 40, in translate

support_list = ['en', 'zh', 'ru', 'es', 'fr', 'ar', 'tr', 'pt', 'it', 'th', 'id', 'vi']
if to_language not in support_list:
    return rsp.failed('閿欒鐨勮瑷€绫诲瀷')

return rsp.success(ts.alibaba(text, to_language=to_language, professional_field='general'))  # ("general","message","offer")

File "/usr/local/python3/lib/python3.6/site-packages/translators/alibaba.py", line 127, in alibaba_api dmtrack_pageid = self.get_dmtrack_pageid(origin_res)

    if if_check_language:
        check_result = self.check_language(from_language,to_language,ss,biz_type,dmtrack_pageid,proxies)
        if not check_result:
            raise ValueError('from_language[{}] or to_language[{}] is not supported!'.format(from_language,to_language))

    i,data,ts_result = 0,{},[]
    while not ts_result and i<3:
        res = ss.post(self.api_url, data=form_data, params={"dmtrack_pageid": dmtrack_pageid}, proxies=proxies)
        data = res.json()

ValueError: from_language[en] or to_language[en] is not supported! This is the Copy/Paste friendly version of the traceback.

Traceback (most recent call last): File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2309, in call return self.wsgi_app(environ, start_response) File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/usr/local/python3/lib/python3.6/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(*args, kwargs))) File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/python3/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/python3/lib/python3.6/site-packages/flask_cors/extension.py", line 165, in wrapped_function return cors_after_request(app.make_response(f(args, kwargs))) File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/python3/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/python3/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](req.view_args) File "/www/python/PersonalHomepage/backend/app/limiter.py", line 20, in decorated_function return f(args, kwargs) File "/usr/local/python3/lib/python3.6/site-packages/flask_limiter/extension.py", line 702, in __inner return obj(*a, *k) File "/www/python/PersonalHomepage/backend/app/privilege/privilege_control.py", line 80, in decorated_function return f(args, **kwargs) File "/www/python/PersonalHomepage/backend/app/translator/api.py", line 40, in translate return rsp.success(ts.alibaba(text, to_language=to_language, professional_field='general')) # ("general","message","offer") File "/usr/local/python3/lib/python3.6/site-packages/translators/alibaba.py", line 127, in alibaba_api raise ValueError('from_language[{}] or to_language[{}] is not supported!'.format(from_language,to_language)) ValueError: from_language[en] or to_language[en] is not supported! The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more. Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter. Console Locked The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.

PIN: