incomplete read error with python google app engine, using webapp2, WSGI - python

I get this internal server error whenever I run the code. I'm trying to save the content of a page I retrieved, into datastore by splitting it into a list of words. basically it's a crawler, and has to save each word and the url of the page as a pair.
here is the traceback:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\Samson\Documents\searchengineapp\searchapp\crawlHandler.py", line 26, in post
if spider.crawl_web():
File "C:\Users\Samson\Documents\searchengineapp\searchapp\crawl\crawler.py", line 52, in crawl_web
add_page_to_index(page, content)
File "C:\Users\Samson\Documents\searchengineapp\searchapp\crawl\indexin.py", line 42, in add_page_to_index
add_to_index(word, url)
File "C:\Users\Samson\Documents\searchengineapp\searchapp\crawl\indexin.py", line 29, in add_to_index
index.put()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\model.py", line 3432, in _put
return self._put_async(**ctx_options).get_result()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\tasklets.py", line 326, in get_result
self.check_success()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\tasklets.py", line 369, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\context.py", line 810, in put
key = yield self._put_batcher.add(entity, options)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\tasklets.py", line 369, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\context.py", line 343, in _put_tasklet
keys = yield self._conn.async_put(options, datastore_entities)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\ndb\tasklets.py", line 455, in _on_rpc_completion
result = rpc.get_result()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 613, in get_result
return self.__get_result_hook(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", line 1881, in __put_hook
self.check_rpc_success(rpc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", line 1371, in check_rpc_success
rpc.check_success()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 579, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 157, in _WaitImpl
self.request, self.response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 201, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 227, in _MakeRealSyncCall
encoded_response = self._server.Send(self._path, encoded_request)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 394, in Send
response = f.read()
File "C:\Python27\lib\socket.py", line 351, in read
data = self._sock.recv(rbufsize)
File "C:\Python27\lib\httplib.py", line 549, in read
return self._read_chunked(amt)
File "C:\Python27\lib\httplib.py", line 603, in _read_chunked
raise IncompleteRead(''.join(value))
IncompleteRead: IncompleteRead(52 bytes read)
I honestly don't know where the problem is coming from. please I need help. Thanks

Related

I am trying to install plyvel and getting error

C:\>pip install plyvel-win32
ERROR: Exception:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
status = self.run(options, args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
return func(self, options, args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
requirement_set = resolver.resolve(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
result = self._result = resolver.resolve(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
return bool(self._sequence)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
return any(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 29, in _iter_built
for version, func in infos:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 272, in iter_index_candidate_infos
result = self._finder.find_best_candidate(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\package_finder.py", line 851, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\package_finder.py", line 798, in find_all_candidates
page_candidates = list(page_candidates_it)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\sources.py", line 134, in page_candidates
yield from self._candidates_from_page(self._link)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\package_finder.py", line 758, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\collector.py", line 490, in fetch_page
return _get_html_page(location, session=self.session)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\collector.py", line 400, in _get_html_page
resp = _get_html_response(url, session=session)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\index\collector.py", line 115, in _get_html_response
resp = session.get(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_internal\network\session.py", line 454, in request
return super().request(method, url, *args, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\sessions.py", line 532, in request
settings = self.merge_environment_settings(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\sessions.py", line 711, in merge_environment_settings
env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\utils.py", line 797, in get_environ_proxies
if should_bypass_proxies(url, no_proxy=no_proxy):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\utils.py", line 781, in should_bypass_proxies
bypass = proxy_bypass(parsed.hostname)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\utils.py", line 102, in proxy_bypass
return proxy_bypass_registry(host)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\site-packages\pip\_vendor\requests\utils.py", line 67, in proxy_bypass_registry
proxyEnable = int(winreg.QueryValueEx(internetSettings,
ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00'
is error I am getting. Anyone can help me?

I'm trying to install Google Assistant but encounter an error that I can't find a solution anywhere

I'm trying to install Google Assistant but I encountered an error like this:
Someone please help me fix this
I followed the instruction in this video https://www.youtube.com/watch?v=yfVMXq6mEXk&t=623s
Press Enter to send a new request...
INFO:root:Recording audio request.
INFO:root:Transcript of user request: "hello".
INFO:root:Transcript of user request: "help".
INFO:root:Transcript of user request: "hello".
INFO:root:Transcript of user request: "hello".
INFO:root:End of audio request detected.
INFO:root:Stopping recording.
INFO:root:Transcript of user request: "hello".
INFO:root:Playing assistant response.
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python39\lib\site-packages\googlesamples\assistant\grpc\pushtotalk.py", line 469, in <module>
main()
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\googlesamples\assistant\grpc\pushtotalk.py", line 458, in main
continue_conversation = assistant.assist()
File "C:\Program Files\Python39\lib\site-packages\tenacity\__init__.py", line 241, in wrapped_f
return self.call(f, *args, **kw)
File "C:\Program Files\Python39\lib\site-packages\tenacity\__init__.py", line 329, in call
do = self.iter(result=result, exc_info=exc_info,
File "C:\Program Files\Python39\lib\site-packages\tenacity\__init__.py", line 279, in iter
return fut.result()
File "C:\Program Files\Python39\lib\concurrent\futures\_base.py", line 433, in result
return self.__get_result()
File "C:\Program Files\Python39\lib\concurrent\futures\_base.py", line 389, in __get_result
raise self._exception
File "C:\Program Files\Python39\lib\site-packages\tenacity\__init__.py", line 333, in call
result = fn(*args, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\googlesamples\assistant\grpc\pushtotalk.py", line 154, in assist
self.conversation_stream.write(resp.audio_out.audio_data)
File "C:\Program Files\Python39\lib\site-packages\googlesamples\assistant\grpc\audio_helpers.py", line 326, in write
buf = normalize_audio_buffer(buf, self.volume_percentage)
File "C:\Program Files\Python39\lib\site-packages\googlesamples\assistant\grpc\audio_helpers.py", line 57, in normalize_audio_buffer
buf = arr.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'```

How to fix requests (urllib3) work with app engine?

I use requests library (or urllib3), trying to get xml page from web site. And my code is working, but when i use it in app engine it shows an error
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\main.py", line 51, in get
class_list = get_class_list()
File "C:\Users\Kirill\Desktop\Schedule\Schedule\get_class_urllib3.py", line 6, in get_class_list
r = http.request('POST', 'http://sgo.volganet.ru/lacc.asp?Function=GetClassListForSchool&SchoolID=1460')
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\request.py", line 73, in request
**urlopen_kw)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\request.py", line 151, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\poolmanager.py", line 165, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\connectionpool.py", line 558, in urlopen
body=body, headers=headers)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\connectionpool.py", line 389, in _make_request
assert_header_parsing(httplib_response.msg)
File "C:\Users\Kirill\Desktop\Schedule\Schedule\urllib3\util\response.py", line 49, in assert_header_parsing
type(headers)))
TypeError: expected httplib.Message, got <type 'instance'>.
So can you help me to fix this problem or suggest any module I can use in app angine to create post request to differen site.
I would recommend using the API provided by AppEngine: urlfetch.fetch()

python: error while using strptime and timedelta

I'am trying to calculate a due date. Here's the code:
from datetime import datetime,timedelta
commande = self.pool.get('commandes').browse(cr, uid,commande_id,context=context)
date_commande= datetime.strptime(commande.date_commande, "%Y-%m-%d").date()
res['due_date']=date_commande+timedelta(days=20)
the field due_date is date type
I get this error:
XmlHttpRequestError INTERNAL SERVER ERROR
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
I tested the code without timedelta and i still got the same error
the traceback:
Traceback (most recent call last):
File "werkzeug\serving.py", line 159, in run_wsgi
File "werkzeug\serving.py", line 146, in execute
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\service\wsgi_server.py", line 417, in application
return application_unproxied(environ, start_response)
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\service\wsgi_server.py", line 403, in application_unproxied
result = handler(environ, start_response)
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 528, in __call__
return self.dispatch(environ, start_response)
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 487, in __call__
return self.app(environ, start_wrapped)
File "werkzeug\wsgi.py", line 411, in __call__
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 487, in __call__
return self.app(environ, start_wrapped)
File "werkzeug\wsgi.py", line 411, in __call__
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 487, in __call__
return self.app(environ, start_wrapped)
File "werkzeug\wsgi.py", line 411, in __call__
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 553, in dispatch
result = handler(request)
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 618, in <lambda>
return lambda request: JsonRequest(request).dispatch(method)
File "C:\Program Files (x86)\OpenERP 7.0-20140120-002508\Server\server\openerp\addons\web\http.py", line 251, in dispatch
body = simplejson.dumps(response)
File "simplejson\__init__.py", line 286, in dumps
File "simplejson\encoder.py", line 228, in encode
File "simplejson\encoder.py", line 515, in _iterencode
File "simplejson\encoder.py", line 483, in _iterencode_dict
File "simplejson\encoder.py", line 483, in _iterencode_dict
File "simplejson\encoder.py", line 483, in _iterencode_dict
File "simplejson\encoder.py", line 525, in _iterencode
File "simplejson\encoder.py", line 202, in default
TypeError: datetime.date(2014, 3, 3) is not JSON serializable
Please can someone tell me where i made a mistake?
Thanks
Your problem in the response encoding to JSON as it can't parse datetime(date) to JSON, you should convert it to string using strftime function.
so you can try:
from datetime import datetime,timedelta
commande = self.pool.get('commandes').browse(cr, uid,commande_id,context=context)
date_commande= datetime.strptime(commande.date_commande, "%Y-%m-%d").date()
res['due_date']= datetime.strftime(date_commande+timedelta(days=20),"%Y-%m-%d")

How to use gaesessions in google-app-engine

I'm new to Python (as well as GAE), I'm trying to include gaesessions in my application, this is exactly what I did:
I copied the gaesessions folder to my src folder (the folder includes __init__.py file)
and added this to my working code:
from gaesessions import get_current_session
session = get_current_session()
I received the following error:
Traceback (most recent call last): File "C:\Program
Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line
174, in Handle
result = handler(self._environ, self._StartResponse)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1519, in
__call__
response = self._internal_error(e)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1511, in
__call__
rv = self.handle_exception(request, response, e)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1505, in
__call__
rv = self.router.dispatch(request, response)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1253, in
default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 1077, in
__call__
return handler.dispatch()
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 547, in
dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program
Files\Google\google_appengine\lib\webapp2\webapp2.py", line 545, in
dispatch
return method(*args, **kwargs)
File "D:....\src\helloworld.py", line 13, in get
session = get_current_session()
File "D:....\src\gaesessions\__init__.py", line 36, in
get_current_session
return _tls.current_session
File "C:\Python27\lib\_threading_local.py", line 193, in
__getattribute__
return object.__getattribute__(self, name)
You've omitted the actual exception from your stack trace, but I'm guessing it's this:
AttributeError: 'local' object has no attribute 'current_session'
If so, you've most likely skipped the middleware configuration step. Create an appengine_config.py per the instructions and restart the dev server; this should resolve your error.

Categories

Resources