Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
66acd182
Commit
66acd182
authored
Jul 21, 2020
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Gdrive integration (Error Handling on Callback and wording)
parent
93a0217d
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
36 additions
and
29 deletions
+36
-29
gdrive.py
cps/gdrive.py
+8
-9
gdriveutils.py
cps/gdriveutils.py
+10
-2
config_edit.html
cps/templates/config_edit.html
+1
-1
messages.po
cps/translations/cs/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/es/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/fi/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/fr/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/hu/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/it/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/ja/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/km/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/nl/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/pl/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/ru/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/sv/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/tr/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/uk/LC_MESSAGES/messages.po
+1
-1
messages.po
cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po
+1
-1
messages.pot
messages.pot
+1
-1
No files found.
cps/gdrive.py
View file @
66acd182
...
...
@@ -34,18 +34,17 @@ from flask import Blueprint, flash, request, redirect, url_for, abort
from
flask_babel
import
gettext
as
_
from
flask_login
import
login_required
try
:
from
googleapiclient.errors
import
HttpError
except
ImportError
:
pass
from
.
import
logger
,
gdriveutils
,
config
,
ub
,
calibre_db
from
.web
import
admin_required
gdrive
=
Blueprint
(
'gdrive'
,
__name__
)
log
=
logger
.
create
()
try
:
from
googleapiclient.errors
import
HttpError
except
ImportError
as
err
:
log
.
debug
((
"Cannot import googleapiclient, using gdrive will not work:
%
s"
,
err
))
current_milli_time
=
lambda
:
int
(
round
(
time
()
*
1000
))
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
...
...
@@ -73,7 +72,7 @@ def google_drive_callback():
credentials
=
gdriveutils
.
Gauth
.
Instance
()
.
auth
.
flow
.
step2_exchange
(
auth_code
)
with
open
(
gdriveutils
.
CREDENTIALS
,
'w'
)
as
f
:
f
.
write
(
credentials
.
to_json
())
except
ValueError
as
error
:
except
(
ValueError
,
AttributeError
)
as
error
:
log
.
error
(
error
)
return
redirect
(
url_for
(
'admin.configuration'
))
...
...
@@ -94,7 +93,7 @@ def watch_gdrive():
try
:
result
=
gdriveutils
.
watchChange
(
gdriveutils
.
Gdrive
.
Instance
()
.
drive
,
notification_id
,
'web_hook'
,
address
,
gdrive_watch_callback_token
,
current_milli_time
()
+
604800
*
1000
)
config
.
config_google_drive_watch_changes_response
=
json
.
dumps
(
result
)
#
config.config_google_drive_watch_changes_response = json.dumps(result)
# after save(), config_google_drive_watch_changes_response will be a json object, not string
config
.
save
()
except
HttpError
as
e
:
...
...
@@ -118,7 +117,7 @@ def revoke_watch_gdrive():
last_watch_response
[
'resourceId'
])
except
HttpError
:
pass
config
.
config_google_drive_watch_changes_response
=
None
config
.
config_google_drive_watch_changes_response
=
{}
config
.
save
()
return
redirect
(
url_for
(
'admin.configuration'
))
...
...
cps/gdriveutils.py
View file @
66acd182
...
...
@@ -36,7 +36,9 @@ try:
from
apiclient
import
errors
from
httplib2
import
ServerNotFoundError
gdrive_support
=
True
except
ImportError
:
importError
=
None
except
ImportError
as
err
:
importError
=
err
gdrive_support
=
False
from
.
import
logger
,
cli
,
config
...
...
@@ -52,6 +54,8 @@ if gdrive_support:
logger
.
get
(
'googleapiclient.discovery_cache'
)
.
setLevel
(
logger
.
logging
.
ERROR
)
if
not
logger
.
is_debug_enabled
():
logger
.
get
(
'googleapiclient.discovery'
)
.
setLevel
(
logger
.
logging
.
ERROR
)
else
:
log
.
debug
(
"Cannot import pydrive,httplib2, using gdrive will not work:
%
s"
,
importError
)
class
Singleton
:
...
...
@@ -99,7 +103,11 @@ class Singleton:
@
Singleton
class
Gauth
:
def
__init__
(
self
):
self
.
auth
=
GoogleAuth
(
settings_file
=
SETTINGS_YAML
)
try
:
self
.
auth
=
GoogleAuth
(
settings_file
=
SETTINGS_YAML
)
except
NameError
as
error
:
log
.
error
(
error
)
self
.
auth
=
None
@
Singleton
...
...
cps/templates/config_edit.html
View file @
66acd182
...
...
@@ -41,7 +41,7 @@
</div>
{% else %}
{% if show_authenticate_google_drive and g.user.is_authenticated and not config.config_use_google_drive %}
<div
>
{{_('Please hit s
ubmit
to continue with setup')}}
</div>
<div
>
{{_('Please hit s
ave
to continue with setup')}}
</div>
{% endif %}
{% if not g.user.is_authenticated %}
<div
>
{{_('Please finish Google Drive setup after login')}}
</div>
...
...
cps/translations/cs/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1556,7 +1556,7 @@ msgid "Authenticate Google Drive"
msgstr "Ověřit Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Klikněte na odeslat pro pokračování v nastavení"
#: cps/templates/config_edit.html:47
...
...
cps/translations/de/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Google Drive authentifizieren"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Bitte auf Abschicken drücken, um mit dem Setup fortzufahren"
#: cps/templates/config_edit.html:47
...
...
cps/translations/es/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1560,7 +1560,7 @@ msgid "Authenticate Google Drive"
msgstr "Autentificar Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Por favor, pulsa enviar para continuar con la configuración"
#: cps/templates/config_edit.html:47
...
...
cps/translations/fi/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Autentikoi Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Ole hyvä ja paina lähetä jatkaaksesi asennusta"
#: cps/templates/config_edit.html:47
...
...
cps/translations/fr/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1571,7 +1571,7 @@ msgid "Authenticate Google Drive"
msgstr "Authentification Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Veuillez cliquer sur soumettre pour continuer l’initialisation"
#: cps/templates/config_edit.html:47
...
...
cps/translations/hu/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Google Drive hitelesítés"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "A beállítás folytatásához kattints a Küldés gombra"
#: cps/templates/config_edit.html:47
...
...
cps/translations/it/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1556,7 +1556,7 @@ msgid "Authenticate Google Drive"
msgstr "Autenticazione Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Per favore premi invio per proseguire con la configurazione"
#: cps/templates/config_edit.html:47
...
...
cps/translations/ja/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Googleドライブを認証"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "決定を押して設定を続けてください"
#: cps/templates/config_edit.html:47
...
...
cps/translations/km/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1558,7 +1558,7 @@ msgid "Authenticate Google Drive"
msgstr "វាយបញ្ចូលគណនី Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr ""
#: cps/templates/config_edit.html:47
...
...
cps/translations/nl/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1558,7 +1558,7 @@ msgid "Authenticate Google Drive"
msgstr "Google Drive goedkeuren"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Druk op 'Opslaan' om door te gaan met instellen"
#: cps/templates/config_edit.html:47
...
...
cps/translations/pl/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1570,7 +1570,7 @@ msgid "Authenticate Google Drive"
msgstr "Uwierzytelnij Dysk Google"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Kliknij przycisk, aby kontynuować instalację"
#: cps/templates/config_edit.html:47
...
...
cps/translations/ru/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1558,7 +1558,7 @@ msgid "Authenticate Google Drive"
msgstr "Аутентификация Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Пожалуйста, нажмите «Отправить», чтобы продолжить настройку"
#: cps/templates/config_edit.html:47
...
...
cps/translations/sv/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Autentisera Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Klicka på skicka för att fortsätta med installationen"
#: cps/templates/config_edit.html:47
...
...
cps/translations/tr/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "Google Drive Doğrula"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "Kuruluma devam etmek için Gönder'e tıklayın"
#: cps/templates/config_edit.html:47
...
...
cps/translations/uk/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1556,7 +1556,7 @@ msgid "Authenticate Google Drive"
msgstr "Автентифікація Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr ""
#: cps/templates/config_edit.html:47
...
...
cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po
View file @
66acd182
...
...
@@ -1557,7 +1557,7 @@ msgid "Authenticate Google Drive"
msgstr "认证 Google Drive"
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr "请点击提交以继续设置"
#: cps/templates/config_edit.html:47
...
...
messages.pot
View file @
66acd182
...
...
@@ -1556,7 +1556,7 @@ msgid "Authenticate Google Drive"
msgstr ""
#: cps/templates/config_edit.html:44
msgid "Please hit s
ubmit
to continue with setup"
msgid "Please hit s
ave
to continue with setup"
msgstr ""
#: cps/templates/config_edit.html:47
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment