mrf345 / flask_googletrans Goto Github PK
View Code? Open in Web Editor NEWGoogletrans google translation flask extension
License: MIT License
Googletrans google translation flask extension
License: MIT License
When I run pytest
pytest
There are three test failed:
=================================================== short test summary info ===================================================
FAILED test_fg.py::test_translate_multi_new_mod - AttributeError: 'NoneType' object has no attribute 'group'
FAILED test_fg.py::test_translator_false_input - FileNotFoundError: [WinError 2] The system cannot find the file specified: '...
FAILED test_fg.py::test_translate_failsafe - AssertionError: assert 'falsely modified' == 'something to say'
I am wondering what caused this. I am currently trying to see if there is any flaky tests in test design so I need to get all tests pass at first.
First, I use pip install Flask-Googletrans
and successfully installed the extension.
My app.py is as bellow:
`from flask import Flask, render_template
from flask_googletrans import translator
app = Flask(name)
ts = translator(app)
@app.route('/')
def hello_world():
title = "hello"
title = ts.translate(text=title, src='en', dest=['ja'])
return render_template("index.html", title=title)
if name == 'main':
app.run()
the jinja template file is as bellow:
When running on http://127.0.0.1:5000, I got errors as bellow:
[2022-09-12 15:55:46,765] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "D:\Python\workplace\testtranslate\app.py", line 10, in hello_world title = ts.translate(text=title, src='en', dest=['ja']) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask_googletrans\__init__.py", line 171, in translate translation = translator.translate( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 182, in translate data = self._translate(text, dest, src, kwargs) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 78, in _translate token = self.token_acquirer.do(text) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 194, in do self._update() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 54, in _update r = self.client.get(self.host) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 755, in get return self.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 600, in request return self.send( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 620, in send response = self.send_handling_redirects( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 647, in send_handling_redirects response = self.send_handling_auth( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 684, in send_handling_auth response = self.send_single_request(request, timeout) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 714, in send_single_request ) = transport.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\http_proxy.py", line 110, in request return self._tunnel_request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\http_proxy.py", line 191, in _tunnel_request proxy_response = proxy_connection.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 65, in request self.socket = self._open_socket(timeout) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 85, in _open_socket return self.backend.open_tcp_stream( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_backends\sync.py", line 139, in open_tcp_stream return SyncSocketStream(sock=sock) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_exceptions.py", line 12, in map_exceptions raise to_exc(exc) from None httpcore._exceptions.ConnectTimeout: _ssl.c:1091: The handshake operation timed out
What should I do to deal with the error? Thank you for your time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.