From 7b24c59463e13d92aae11f2affbd7f0d8ffd7293 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Tue, 1 Mar 2022 15:12:39 +0200 Subject: [PATCH] Debug for error logging --- modules/change_email.py | 2 +- modules/change_password.py | 2 +- modules/gui_manager.py | 2 +- modules/http_status.py | 2 +- modules/manager.py | 2 +- modules/package_edit.py | 6 ++++-- modules/source.py | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/change_email.py b/modules/change_email.py index 4624e24..6db4e83 100644 --- a/modules/change_email.py +++ b/modules/change_email.py @@ -24,7 +24,7 @@ def change(email): r_code = handle(requests.put(horsy_vars.protocol + horsy_vars.server_url + '/users', json={'auth': auth, 'email': email}).status_code) if r_code[1] not in [200, 201]: - gui.cpopup("Error", r_code[1]) + gui.cpopup("Error", r_code[0]) except: gui.cpopup('Error', 'Unexpected error.') threading.Thread(target=change_in_new_thread).start() diff --git a/modules/change_password.py b/modules/change_password.py index 75c5f87..04a3439 100644 --- a/modules/change_password.py +++ b/modules/change_password.py @@ -29,6 +29,6 @@ def change(oldpass, newpass): gui.cpopup("Changing password", handle(requests.put(horsy_vars.protocol + horsy_vars.server_url + '/users', json={'auth': get_auth(True, login_ui, QtWidgets.QMainWindow()), - 'password': newpass}).status_code)[1]) + 'password': newpass}).status_code)[0]) except: gui.popup('Error', 'Unexpected error.') diff --git a/modules/gui_manager.py b/modules/gui_manager.py index a66515d..66d1470 100644 --- a/modules/gui_manager.py +++ b/modules/gui_manager.py @@ -18,7 +18,7 @@ def install(package): r = json.loads(r) if r_code[1] not in [200, 201]: - cpopup("Error", r_code[1]) + cpopup("Error", r_code[0]) try: UiDownloadWindow.show() diff --git a/modules/http_status.py b/modules/http_status.py index 730b091..074fa36 100644 --- a/modules/http_status.py +++ b/modules/http_status.py @@ -68,7 +68,7 @@ codes = {'CONTINUE': 100, 401: 'You are not authorized to access this resource, please login', 402: 'PAYMENT_REQUIRED', 403: 'Forbidden, you do not have permission to access this resource or you need to log in', - 404: 'Not found', + 404: 'Not found or you do not have permission to access this resource', 405: 'METHOD_NOT_ALLOWED', 406: 'NOT_ACCEPTABLE', 407: 'PROXY_AUTHENTICATION_REQUIRED', diff --git a/modules/manager.py b/modules/manager.py index b1bd4b8..f0b3233 100644 --- a/modules/manager.py +++ b/modules/manager.py @@ -17,7 +17,7 @@ def install(package): r = json.loads(r) if r_code[1] not in [200, 201]: - return r_code[1] + return r_code[0] try: # Inform the user diff --git a/modules/package_edit.py b/modules/package_edit.py index b8ea83b..8836641 100644 --- a/modules/package_edit.py +++ b/modules/package_edit.py @@ -15,7 +15,7 @@ def edit(package, UiPackageWindow): try: r_code = handle(r.status_code) if r_code[1] not in [200, 201]: - gui.cpopup("Error", r_code[1]) + gui.cpopup("Error", r_code[0]) r = r.text r = json.loads(r) except: @@ -43,6 +43,8 @@ def edit(package, UiPackageWindow): 'run': (lambda x: x if x != '' else None)(package_ui.main_exe_box.text()) } - handle(requests.put(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages", json=body).status_code) + gui.cpopup("Updating", + handle(requests.put(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages", + json=body).status_code)[0]) package_ui.update_button.clicked.connect(send) diff --git a/modules/source.py b/modules/source.py index ef49a8a..5b2381e 100644 --- a/modules/source.py +++ b/modules/source.py @@ -10,7 +10,7 @@ def get_source(package): r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}") r_code = handle(r.status_code) if r_code[1] not in [200, 201]: - return r_code[1] + return r_code[0] r = r.text r = json.loads(r)