From ea98323c067acd1577a69801a39b10b10ec9f7d8 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 3 Feb 2019 16:38:27 +0100 Subject: [PATCH] Fixes Google Drive Improved user guidance for Google Drive Improved Errorhandling for Google Drive Update french translation Added ukranian translation Improvements on updater: calibre-web.log1, calibre-web.log2, gdrive_credentials, settings.yaml, gdrive.db, .git are no longer deleted upon update --- cps/gdriveutils.py | 11 +- cps/helper.py | 4 +- cps/templates/config_edit.html | 13 +- cps/translations/de/LC_MESSAGES/messages.mo | Bin 47593 -> 47875 bytes cps/translations/de/LC_MESSAGES/messages.po | 382 +- cps/translations/es/LC_MESSAGES/messages.mo | Bin 47028 -> 47833 bytes cps/translations/es/LC_MESSAGES/messages.po | 382 +- cps/translations/fr/LC_MESSAGES/messages.mo | Bin 48625 -> 49602 bytes cps/translations/fr/LC_MESSAGES/messages.po | 1745 +++++-- cps/translations/hu/LC_MESSAGES/messages.mo | Bin 47284 -> 48094 bytes cps/translations/hu/LC_MESSAGES/messages.po | 1642 ++++++- cps/translations/iso639.pickle | 4127 ++++++++++++----- cps/translations/it/LC_MESSAGES/messages.mo | Bin 44955 -> 45765 bytes cps/translations/it/LC_MESSAGES/messages.po | 1663 ++++++- cps/translations/ja/LC_MESSAGES/messages.mo | Bin 49069 -> 49886 bytes cps/translations/ja/LC_MESSAGES/messages.po | 382 +- cps/translations/km/LC_MESSAGES/messages.mo | Bin 57365 -> 58110 bytes cps/translations/km/LC_MESSAGES/messages.po | 382 +- cps/translations/nl/LC_MESSAGES/messages.mo | Bin 46159 -> 46973 bytes cps/translations/nl/LC_MESSAGES/messages.po | 1653 ++++++- cps/translations/pl/LC_MESSAGES/messages.mo | Bin 45632 -> 46437 bytes cps/translations/pl/LC_MESSAGES/messages.po | 1665 ++++++- cps/translations/ru/LC_MESSAGES/messages.mo | Bin 58036 -> 58826 bytes cps/translations/ru/LC_MESSAGES/messages.po | 1645 ++++++- cps/translations/sv/LC_MESSAGES/messages.mo | Bin 46582 -> 47395 bytes cps/translations/sv/LC_MESSAGES/messages.po | 382 +- cps/translations/uk/LC_MESSAGES/messages.mo | Bin 0 -> 56164 bytes cps/translations/uk/LC_MESSAGES/messages.po | 2112 +++++++++ .../zh_Hans_CN/LC_MESSAGES/messages.mo | Bin 45335 -> 46152 bytes .../zh_Hans_CN/LC_MESSAGES/messages.po | 1662 ++++++- cps/updater.py | 8 +- cps/web.py | 23 +- messages.pot | 382 +- readme.md | 160 +- 34 files changed, 16270 insertions(+), 4155 deletions(-) create mode 100644 cps/translations/uk/LC_MESSAGES/messages.mo create mode 100644 cps/translations/uk/LC_MESSAGES/messages.po mode change 100755 => 100644 readme.md diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index ffddb9d3..cb36a413 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -20,7 +20,7 @@ try: from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive - from pydrive.auth import RefreshError + from pydrive.auth import RefreshError, InvalidConfigError from apiclient import errors gdrive_support = True except ImportError: @@ -166,7 +166,10 @@ def getDrive(drive=None, gauth=None): # Save the current credentials to a file return GoogleDrive(gauth) if drive.auth.access_token_expired: - drive.auth.Refresh() + try: + drive.auth.Refresh() + except RefreshError as e: + web.app.logger.error("Google Drive error: " + e.message) return drive def listRootFolders(): @@ -454,6 +457,10 @@ def getChangeById (drive, change_id): except (errors.HttpError) as error: web.app.logger.info(error.message) return None + except Exception as e: + web.app.logger.info(e) + return None + # Deletes the local hashes database to force search for new folder names def deleteDatabaseOnChange(): diff --git a/cps/helper.py b/cps/helper.py index 94da9e5c..31d82e73 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -427,6 +427,8 @@ def delete_book(book, calibrepath, book_format): def get_book_cover(cover_path): if ub.config.config_use_google_drive: try: + if not web.is_gdrive_ready(): + return send_from_directory(os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg") path=gd.get_cover_via_gdrive(cover_path) if path: return redirect(path) @@ -434,7 +436,7 @@ def get_book_cover(cover_path): web.app.logger.error(cover_path + '/cover.jpg not found on Google Drive') return send_from_directory(os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg") except Exception as e: - web.app.logger.error("Error Message: "+e.message) + web.app.logger.error("Error Message: " + e.message) web.app.logger.exception(e) # traceback.print_exc() return send_from_directory(os.path.join(os.path.dirname(__file__), "static"),"generic_cover.jpg") diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index bdd72946..cef969d3 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -31,15 +31,19 @@ {% else %} - {% if show_authenticate_google_drive and g.user.is_authenticated %} + {% if show_authenticate_google_drive and g.user.is_authenticated and content.config_use_google_drive %}
{{_('Authenticate Google Drive')}}
{% else %} - {% if show_authenticate_google_drive and not g.user.is_authenticated %} + {% if show_authenticate_google_drive and g.user.is_authenticated and not content.config_use_google_drive %} +
{{_('Please hit submit to continue with setup')}}
+ {% endif %} + {% if not g.user.is_authenticated %}
{{_('Please finish Google Drive setup after login')}}
- {% endif %} - {% if not show_authenticate_google_drive %} + {% endif %} + {% if g.user.is_authenticated %} + {% if not show_authenticate_google_drive %}