From 8af178c19c20e5db06e4b8ee554ee2182e219b76 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 26 Nov 2019 10:46:06 +0100 Subject: [PATCH] Fix for gdrive not working #1081 --- cps/admin.py | 5 ++++- cps/gdriveutils.py | 2 ++ cps/worker.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 25218e51..1862dda8 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -272,6 +272,8 @@ def _configuration_update_helper(): gdrive_secrets = {} gdriveError = gdriveutils.get_error_text(gdrive_secrets) if "config_use_google_drive" in to_save and not config.config_use_google_drive and not gdriveError: + with open(gdriveutils.CLIENT_SECRETS, 'r') as settings: + gdrive_secrets = json.load(settings)['web'] if not gdrive_secrets: return _configuration_result('client_secrets.json is not configured for web application') gdriveutils.update_settings( @@ -413,7 +415,8 @@ def _configuration_result(error_flash=None, gdriveError=None): if gdriveError: gdriveError = _(gdriveError) else: - gdrivefolders = gdriveutils.listRootFolders() + if config.config_use_google_drive and not gdrive_authenticate: + gdrivefolders = gdriveutils.listRootFolders() show_back_button = current_user.is_authenticated show_login_button = config.db_configured and not current_user.is_authenticated diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 4ebbb0c7..d950f738 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -584,5 +584,7 @@ def get_error_text(client_secrets=None): filedata = json.load(settings) if 'web' not in filedata: return 'client_secrets.json is not configured for web application' + if 'redirect_uris' not in filedata['web']: + return 'Callback url (redirect url) is missing in client_secrets.json' if client_secrets: client_secrets.update(filedata['web']) diff --git a/cps/worker.py b/cps/worker.py index e5b4618b..5ccf2d8c 100644 --- a/cps/worker.py +++ b/cps/worker.py @@ -213,7 +213,7 @@ class WorkerThread(threading.Thread): else: self.doLock.release() except Exception as e: - log.exception(e) + log.exception(e) self.doLock.release() if main_thread.is_alive(): time.sleep(1)