I'm trying to do some importing to a DB in App Store 1.9.26, in python 2.7.9, and to do so,I would like to get some logging so I can inspect some variables and have a look on whjt is happening
import logging
[...]
updateDueDate = '2016.3.15'
fmt ='%Y.%m.%d'
fechalinea = datetime.datetime.strptime(updateDueDate,fmt)
fecha_aviso = avisoDB.modificacion.due_date.strftime(fmt)
logging.error = ('Date Call= %s, Date DB= %s' %(fecha_aviso, fechalinea))
Which should be pretty straightforward, but its not working. I think I mess up my python instalation or something that has nothing to do with my code, since the output I get from the devserver is:
TypeError("'str' object is not callable",)
TypeError("'str' object is not callable",)
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
INFO 2015-11-22 16:44:48,554 module.py:809] default: "POST /admin/filemanager HTTP/1.1" 500 -
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 272, in __call__
return app(environ, start_response)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 314, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 154, in __call__
response = self.handle_normal_request(environ)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 184, in handle_normal_request
self._PYTHON_LIB_DIR)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/runtime.py", line 152, in HandleRequest
error)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 329, in HandleRequest
return WsgiRequest(environ, handler_name, url, post_data, error).Handle()
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 279, in Handle
logging.exception('')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1609, in exception
error(msg, *args, **kwargs)
TypeError: 'str' object is not callable
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 272, in __call__
return app(environ, start_response)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 314, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 154, in __call__
response = self.handle_normal_request(environ)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 184, in handle_normal_request
self._PYTHON_LIB_DIR)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/runtime.py", line 152, in HandleRequest
error)
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 329, in HandleRequest
return WsgiRequest(environ, handler_name, url, post_data, error).Handle()
File "/Applications/GoogleAppEngineLauncher 2.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 279, in Handle
logging.exception('')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1609, in exception
error(msg, *args, **kwargs)
TypeError: 'str' object is not callable
INFO 2015-11-22 16:44:48,647 module.py:809] default: "GET /favicon.ico HTTP/1.1" 200 15086
Tried to upgrade python and GAE launcher, google for this problem, but with all the different options I get the same errors, and I'm pretty sure it has nothing to do with my code, but... any one has any idea on what is happening?
Thanks
logging.error = assigns the right-hand-side (in your case, a string) to attribute error of module logging, replacing its previous value (which was a function).
When any Python code (yours or in the SDK) later calls logging.error (which you've set to a string), of course it will produce TypeError("'str' object is not callable",)!
I think I mess up my python instalation
Yes you did, by assigning a string to logging.error.
or something that has nothing to do with my code
It has everything to do with your code -- it's your code that does the mistaken assigning!
Related
I am working in ubuntu 18.04 and Google App Engine python2.7. Because working with python2.7 I can only use boto and not boto3. I am however receiving this error and can't seem to fix it...
ERROR 2021-05-12 12:17:29,792 webapp2.py:1552] 'module' object has no attribute 'HTTPSConnection'
Traceback (most recent call last):
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/depotter/Downloads/google-cloud-sdk-282.0.0-linux-x86_64/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/home/depotter/projects/mwcentral/server/./online_ordering/ctg/menu.py", line 204, in post
self.send_menu(company_key, store_id, timestamp)
File "/home/depotter/projects/mwcentral/server/./online_ordering/ctg/menu.py", line 257, in send_menu
result = self.upload_menu(menu, company_key_id, store_id)
File "/home/depotter/projects/mwcentral/server/./online_ordering/ctg/menu.py", line 295, in upload_menu
key.set_contents_from_string(file)
File "/home/depotter/projects/mwcentral/lib/boto/s3/key.py", line 1442, in set_contents_from_string
encrypt_key=encrypt_key)
File "/home/depotter/projects/mwcentral/lib/boto/s3/key.py", line 1309, in set_contents_from_file
chunked_transfer=chunked_transfer, size=size)
File "/home/depotter/projects/mwcentral/lib/boto/s3/key.py", line 762, in send_file
chunked_transfer=chunked_transfer, size=size)
File "/home/depotter/projects/mwcentral/lib/boto/s3/key.py", line 963, in _send_file_internal
query_args=query_args
File "/home/depotter/projects/mwcentral/lib/boto/s3/connection.py", line 671, in make_request
retry_handler=retry_handler
File "/home/depotter/projects/mwcentral/lib/boto/connection.py", line 1071, in make_request
retry_handler=retry_handler)
File "/home/depotter/projects/mwcentral/lib/boto/connection.py", line 913, in _mexe
self.is_secure)
File "/home/depotter/projects/mwcentral/lib/boto/connection.py", line 705, in get_http_connection
return self.new_http_connection(host, port, is_secure)
File "/home/depotter/projects/mwcentral/lib/boto/connection.py", line 755, in new_http_connection
connection = http_client.HTTPSConnection(
AttributeError: 'module' object has no attribute 'HTTPSConnection'
Absolutely clueless and any help is appreciated..
See these 2 links. They're both for Python2.6 but they might be similar to Python2.7 or point you in the right direction
HTTPSConnection module missing in Python 2.6 on CentOS 5.2
https://groups.google.com/g/google-analytics-data-export-api/c/JkGWM10-4Bw?pli=1
I want to make a Visual search interface with keywords and category to search sth. Obviously, It needs front-end and back-end data interaction. So after weighing some tools, I have choosed Vue and axios to implement data interaction in the front-end, and django view in the front-end.
In my index.html page, I defined my axios like this.
var param = new URLSearchParams();
param.append('searchKey',this.searchKey);
param.append('category',this.selected);
axios.post("{% url 'main:getCommodityInfo'%}",
param,
{headers:{'X-CSRFToken': this.getCookie('csrftoken')}},)
.then(response=>{
console.log(response);
})
.catch(error=>{
console.log(error);
alert("connection has error")
})
searchKey and category could be acquired by Vue object. Then I post the data to my back-end django view.
def getCommodityInfo(request):
if request.method=="POST":
# To get the POST paramaters
searchKey = request.POST.get('searchKey')
category = request.POST.get('category')
# unique ID for each record for DB
uniqueId = str(uuid4())
print("Enter the view! ",searchKey,category)
# set setting
settings = {
'unique_id': uniqueId,
'USER_AGENT': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
}
# task Id to indentify each spider task
task = scrapyd.schedule('JDSpider', 'getCommodityInfo',
settings=settings, searchKey=searchKey, category=category)
print("It seems everything is running well? ")
print(task,uniqueId)
print("-"*100)
return JsonResponse({'taskId': task, 'uniqueId': uniqueId, 'status': 'started'},safe=False)
Well, the view could acutally get the POST paramaters. But When I am trying to return the status json from view to the axios function, error occurs.
[20/Mar/2019 21:03:08] "GET /main/ HTTP/1.1" 200 7216
[20/Mar/2019 21:03:08] "GET /static/main/axios.min.js HTTP/1.1" 304 0
[20/Mar/2019 21:03:08] "GET /static/main/axios.min.map HTTP/1.1" 304 0
Enter the view! switch Electronics
[20/Mar/2019 21:03:30] "GET /main/?searchKey=switch&category=Electronics HTTP/1.1" 200 7216
It seems everything is running well?
8fdcee984b1011e9b7e5ace010528bab e07cd1ee-efe8-4c23-8457-51732aa57435
----------------------------------------------------------------------------------------------------
[20/Mar/2019 21:03:33] "POST /main/getCommodityInfo/ HTTP/1.1" 200 119
Traceback (most recent call last):
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "D:\Anacaonda\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] The software in your host has aborted an established connection.
[20/Mar/2019 21:03:33] "POST /main/getCommodityInfo/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 11890)
Traceback (most recent call last):
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "D:\Anacaonda\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] The software in your host has aborted an established connection.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "D:\Anacaonda\lib\site-packages\django\core\servers\basehttp.py", line 86, in handle_error
super().handle_error()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Anacaonda\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "D:\Anacaonda\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\Anacaonda\lib\socketserver.py", line 696, in __init__
self.handle()
File "D:\Anacaonda\lib\site-packages\django\core\servers\basehttp.py", line 154, in handle
handler.run(self.server.get_app())
File "D:\Anacaonda\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "D:\Anacaonda\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
I have tried to debug the process, but the code logic is too complicated to understand. I could only find the errors happens when executing
return JsonResponse({'taskId': task, 'uniqueId': uniqueId, 'status': 'started'},safe=False)
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.Thanks in advance.
I' ve looked around and apparently I've got the choice below.
<form action="{%url 'main:getCommodityInfo'%}" method="POST">
Using the form could get the json from the django View after my test. But I don't want to use it in my project instead of axios.
The stacktrace you are getting is a known bug of the wsgiref BaseHandler on Windows.
You can keep track of it here:
https://github.com/python/cpython/pull/9713
and here:
https://bugs.python.org/issue27682
Python 2.6.6 When I get HTML Source from Website It gives Error but it works on 3 version
import urllib
link='https://www.bookabach.co.nz/baches-and-holiday-homes/view/38781/'
f=urllib.urlopen(link)
Error as:
Traceback (most recent call last): File "", line 1,
in
f=urllib.urlopen(link) File "E:\Python26\lib\urllib.py", line 86, in urlopen
return opener.open(url) File "E:\Python26\lib\urllib.py", line 207, in open
return getattr(self, name)(url) File "E:\Python26\lib\urllib.py", line 441, in open_https
h.endheaders() File "E:\Python26\lib\httplib.py", line 908, in endheaders
self._send_output() File "E:\Python26\lib\httplib.py", line 780, in _send_output
self.send(msg) File "E:\Python26\lib\httplib.py", line 739, in send
self.connect() File "E:\Python26\lib\httplib.py", line 1116, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) File "E:\Python26\lib\ssl.py", line 338, in
wrap_socket
suppress_ragged_eofs=suppress_ragged_eofs) File "E:\Python26\lib\ssl.py", line 120, in init
self.do_handshake() File "E:\Python26\lib\ssl.py", line 279, in do_handshake
self._sslobj.do_handshake() IOError: [Errno socket error] [Errno 1] _ssl.c:490: error:1407742E:SSL
routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
You may just need to disable SSL verification as you're attempting to reach the site over HTTPS.
Similar issue solved here with urllib.
I uninstalled an addon by mistake and has caused me an internal server error, the log file reads:
2016-01-07 00:26:27,355 8253 CRITICAL bitnami_openerp openerp.service.server: Failed to initialize database `bitnami_openerp`.
Traceback (most recent call last):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/service/server.py", line 919, in preload_registries
registry = RegistryManager.new(dbname, update_module=update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/modules/registry.py", line 368, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/modules/loading.py", line 357, in load_modules
registry.setup_models(cr)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/modules/registry.py", line 192, in setup_models
model._setup_fields(cr, SUPERUSER_ID)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/api.py", line 336, in old_api
result = method(recs, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/models.py", line 2987, in _setup_fields
field.setup(self.env)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/fields.py", line 453, in setup
self._setup_related(env)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/fields.py", line 499, in _setup_related
field = recs._fields[name]
KeyError: 'formated_vat'
It would be great if you could help me, please.
INFO 2015-10-09 11:07:31,718 connectionpool.py:695] Starting new HTTPS connection (1): api.sandbox.braintreegateway.com
DEBUG 2015-10-09 11:07:31,724 api_server.py:277] Handled remote_socket.Resolve in 0.0028
DEBUG 2015-10-09 11:07:31,728 api_server.py:277] Handled remote_socket.CreateSocket in 0.0009
DEBUG 2015-10-09 11:07:32,049 api_server.py:277] Handled remote_socket.Connect in 0.3168
DEBUG 2015-10-09 11:07:32,055 api_server.py:272] Exception while handling service_name: "remote_socket"
method: "GetSocketOptions"
request: "\n$d15a35d7-d299-43c1-ba76-8bf4107f8850\022\006\010\001\020\003\032\000"
request_id: "aiUMNcTaLS"
Traceback (most recent call last):
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 247, in _handle_POST
api_response = _execute_request(request).Encode()
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 186, in _execute_request
make_request()
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 181, in make_request
request_id)
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/api/apiproxy_stub.py", line 131, in MakeSyncCall
method(request, response)
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/api/remote_socket/_remote_socket_stub.py", line 56, in WrappedMethod
return method(self, *args, **kwargs)
File "/home/abc/Downloads/google-appengine/google_appengine/google/appengine/api/remote_socket/_remote_socket_stub.py", line 265, in _Dynamic_GetSocketOptions
'Attempt to get blocked socket option.')
ApplicationError: ApplicationError: 5 Attempt to get blocked socket option.
DEBUG 2015-10-09 11:07:32,056 api_server.py:277] Handled remote_socket.GetSocketOptions in 0.0014
INFO 2015-10-09 11:07:32,058 views.py:570] handle_exception
INFO 2015-10-09 21:28:17,317 views.py:559] Traceback (most recent call last):
File "/home/abc/Downloads/google-appengine/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/home/abc/projects/src/views.py", line 806, in get
self._callHandlingMethod(url, self.getRegexps)
File "/home/abc/projects/src/views.py", line 883, in _callHandlingMethod
function(*matched.groups())
File "/home/abc/projects/src/views.py", line 2992, in buy_get
"client_token": braintree.ClientToken.generate(),
File "/home/abc/projects/src/lib/braintree/client_token.py", line 25, in generate
return gateway.generate(params)
File "/home/abc/projects/src/lib/braintree/client_token_gateway.py", line 17, in generate
response = self.config.http().post("/client_token", params)
File "/home/abc/projects/src/lib/braintree/util/http.py", line 49, in post
return self.__http_do("POST", path, params)
File "/home/abc/projects/src/lib/braintree/util/http.py", line 66, in __http_do
status, response_body = http_strategy.http_do(http_verb, full_path, self.__headers(), request_body)
File "/home/abc/projects/src/lib/braintree/util/http.py", line 87, in http_do
timeout=self.config.timeout
File "/home/abc/projects/src/lib/requests/api.py", line 92, in post
return request('post', url, data=data, **kwargs)
File "/home/abc/projects/src/lib/requests/api.py", line 48, in request
return session.request(method=method, url=url, **kwargs)
File "/home/abc/projects/src/lib/requests/sessions.py", line 451, in request
resp = self.send(prep, **send_kwargs)
File "/home/abc/projects/src/lib/requests/sessions.py", line 557, in send
r = adapter.send(request, **kwargs)
File "/home/abc/projects/src/lib/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
This seemed to be a https issue. I have tried different approaches
a) https://github.com/agfor/braintree-python-appengine . Gave me same error
b) I thought this could be the error from this issue - https://urllib3.readthedocs.org/en/latest/security.html#openssl-pyopenssl
But on updating required libraries , I get stuck at OpenSSL.crypto failed import.
Help anyone!
It looks like braintree is trying to use a socket option unsupported by GAE, you can see a list of supported options here https://cloud.google.com/appengine/docs/python/sockets/ which also states that attempting to get an unsupported option will raise an error
Braintree Version - 3.20.0
Requests version - 2.7.0
With the help of my friend , I used the following hack -
in braintree/util/http.py in the method - __http_do
from google.appengine.api import urlfetch
.....
.....
try:
if http_verb in ["POST", "PUT"]:
result = urlfetch.fetch(url=full_path,
payload=request_body,
method=urlfetch.POST,
headers=self.__headers())
logging.debug('result: %r' % result)
status = result.status_code
response_body = result.content
logging.debug(result.content)
else:
status, response_body = http_strategy.http_do(http_verb, full_path, self.__headers(), request_body)
except Exception as e:
.....
.....
Using this hack, I was able to get things working. Hope this helps anybody coming across the same issue.