From cdb1b5265246ee5869d4b2bb471a7fc7eafcd392 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Thu, 16 Aug 2018 21:17:26 +0200 Subject: [PATCH] Bugfix Get gdrive instances (#554, #525) Metadata.db download works again removed DEVELOPMENT constant removed db logging in debug mode (too, noisy, to less information) code refactoring url_for_other_page feed languge set to en-EN update status shos local time instead of UTC Error handling (back to index page) in case of gdrive authenticate aborted Mistyping page register fixed Mistyping bokk fixed Added uploaded books to tasklist (#442) Error handling for failed file update added Code refactoring worker thread Tasks now never show any decimal values Converter function unified removed shell from subprocess call preparation for limiting domain for registering emails Book series can now increased in 0.1 steps (#562) Accordion panels in config are now usable on touch devices like iPad (#545) Gdrive authenticate button only visible after logged in (#525) Fixed misstyping in german translation --- cps/gdriveutils.py | 18 +- cps/templates/admin.html | 21 +- cps/templates/book_edit.html | 2 +- cps/templates/config_edit.html | 28 ++- cps/templates/config_view_edit.html | 12 +- cps/templates/layout.html | 6 +- cps/translations/de/LC_MESSAGES/messages.po | 2 +- cps/ub.py | 7 - cps/web.py | 103 ++++----- cps/worker.py | 218 ++++++++++++-------- 10 files changed, 243 insertions(+), 174 deletions(-) diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 859ddc5d..0c66f6ce 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -3,8 +3,9 @@ try: from pydrive.drive import GoogleDrive from pydrive.auth import RefreshError from apiclient import errors + gdrive_support = True except ImportError: - pass + gdrive_support = False import os from ub import config @@ -259,6 +260,13 @@ def copyDriveFileRemote(drive, origin_file_id, copy_title): print ('An error occurred: %s' % error) return None + +# Download metadata.db from gdrive +def downloadFile(path, filename, output): + f = getFileFromEbooksFolder(path, filename) + f.GetContentFile(output) + + def moveGdriveFolderRemote(origin_file, target_folder): drive = getDrive(Gdrive.Instance().drive) previous_parents = ",".join([parent["id"] for parent in origin_file.get('parents')]) @@ -339,7 +347,7 @@ def uploadFileToEbooksFolder(destFile, f): def watchChange(drive, channel_id, channel_type, channel_address, channel_token=None, expiration=None): - drive = getDrive(drive) + # drive = getDrive(drive) # Watch for all changes to a user's Drive. # Args: # service: Drive API service instance. @@ -382,7 +390,7 @@ def watchFile(drive, file_id, channel_id, channel_type, channel_address, Raises: apiclient.errors.HttpError: if http request to create channel fails. """ - drive = getDrive(drive) + # drive = getDrive(drive) body = { 'id': channel_id, @@ -405,7 +413,7 @@ def stopChannel(drive, channel_id, resource_id): Raises: apiclient.errors.HttpError: if http request to create channel fails. """ - drive = getDrive(drive) + # drive = getDrive(drive) # service=drive.auth.service body = { 'id': channel_id, @@ -415,7 +423,7 @@ def stopChannel(drive, channel_id, resource_id): def getChangeById (drive, change_id): - drive = getDrive(drive) + # drive = getDrive(drive) # Print a single Change resource information. # # Args: diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 62460fa5..daae9edf 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -53,6 +53,9 @@
{{_('Change SMTP settings')}}
+ {% if g.allow_registration %} +
{{_('Edit allowed domains')}}
+ {% endif %}

{{_('Configuration')}}

@@ -79,16 +82,14 @@
{{_('Basic Configuration')}}
{{_('UI Configuration')}}

{{_('Administration')}}

- {% if not development %} -
{{_('Current commit timestamp')}}: {{commit}}
- -

-
{{_('Reconnect to Calibre DB')}}
-
{{_('Restart Calibre-web')}}
-
{{_('Stop Calibre-web')}}
-
{{_('Check for update')}}
- - {% endif %} +
{{_('Current commit timestamp')}}: {{commit}}
+ +

+
{{_('Reconnect to Calibre DB')}}
+
{{_('Restart Calibre-web')}}
+
{{_('Stop Calibre-web')}}
+
{{_('Check for update')}}
+
- +
diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index 051531ec..c0da4643 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -7,10 +7,10 @@
@@ -31,11 +31,15 @@
{% else %} - {% if show_authenticate_google_drive %} + {% if show_authenticate_google_drive and g.user.is_authenticated %} {% else %} + {% if show_authenticate_google_drive and not g.user.is_authenticated %} +
{{_('Please finish Google Drive setup after login')}}
+ {% endif %} + {% if not show_authenticate_google_drive %}