Open staze opened 4 years ago
With Python2 deprecated, it would be good to get this updated for Python3. I managed to get some of it working (by adding paranthesis for print statements, and changing the urlparse import statement), but then it just errors out:
[Mon Apr 27 09:59:25.642587 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] [2020-04-27 09:59:25,639] ERROR in app: Exception on /products [GET] [Mon Apr 27 09:59:25.642625 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] Traceback (most recent call last): [Mon Apr 27 09:59:25.642629 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app [Mon Apr 27 09:59:25.642638 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] response = self.full_dispatch_request() [Mon Apr 27 09:59:25.642641 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request [Mon Apr 27 09:59:25.642644 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] rv = self.handle_user_exception(e) [Mon Apr 27 09:59:25.642646 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception [Mon Apr 27 09:59:25.642649 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] reraise(exc_type, exc_value, tb) [Mon Apr 27 09:59:25.642652 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/_compat.py", line 39, in reraise [Mon Apr 27 09:59:25.642655 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] raise value [Mon Apr 27 09:59:25.642658 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request [Mon Apr 27 09:59:25.642661 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] rv = self.dispatch_request() [Mon Apr 27 09:59:25.642686 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request [Mon Apr 27 09:59:25.642690 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] return self.view_functions[rule.endpoint](**req.view_args) [Mon Apr 27 09:59:25.642692 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/asus/margarita/margarita.py", line 146, in products [Mon Apr 27 09:59:25.642695 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] return json_response({'products': sprodlist, 'branches': catalog_branches.keys()}) [Mon Apr 27 09:59:25.642698 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/local/asus/margarita/margarita.py", line 52, in json_response [Mon Apr 27 09:59:25.642700 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] return Response(json.dumps(r), status=200, mimetype='application/json') [Mon Apr 27 09:59:25.642703 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/lib64/python3.6/json/__init__.py", line 231, in dumps [Mon Apr 27 09:59:25.642705 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] return _default_encoder.encode(obj) [Mon Apr 27 09:59:25.642708 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode [Mon Apr 27 09:59:25.642711 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] chunks = self.iterencode(o, _one_shot=True) [Mon Apr 27 09:59:25.642722 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode [Mon Apr 27 09:59:25.642725 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] return _iterencode(o, 0) [Mon Apr 27 09:59:25.642728 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] File "/usr/lib64/python3.6/json/encoder.py", line 180, in default [Mon Apr 27 09:59:25.642730 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] o.__class__.__name__) [Mon Apr 27 09:59:25.642734 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975] TypeError: Object of type 'dict_keys' is not JSON serializable [Mon Apr 27 09:59:25.642771 2020] [wsgi:error] [pid 41828:tid 139685827593984] [remote 10.174.12.93:59975]
With Python2 deprecated, it would be good to get this updated for Python3. I managed to get some of it working (by adding paranthesis for print statements, and changing the urlparse import statement), but then it just errors out: