diff --git a/cps.py b/cps.py index 3601e4b6..20aa9cac 100755 --- a/cps.py +++ b/cps.py @@ -31,7 +31,7 @@ else: sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vendor')) -from cps import create_app +from cps import create_app, config from cps import web_server from cps.opds import opds from cps.web import web @@ -64,7 +64,8 @@ def main(): app.register_blueprint(about) app.register_blueprint(shelf) app.register_blueprint(admi) - app.register_blueprint(gdrive) + if config.config_use_google_drive: + app.register_blueprint(gdrive) app.register_blueprint(editbook) if kobo_available: app.register_blueprint(kobo) diff --git a/cps/gdrive.py b/cps/gdrive.py index 584c90cf..90b83e64 100644 --- a/cps/gdrive.py +++ b/cps/gdrive.py @@ -123,10 +123,12 @@ def revoke_watch_gdrive(): @gdrive.route("/gdrive/watch/callback", methods=['GET', 'POST']) def on_received_watch_confirmation(): + if not config.config_google_drive_watch_changes_response: + return '' if request.headers.get('X-Goog-Channel-Token') != gdrive_watch_callback_token \ or request.headers.get('X-Goog-Resource-State') != 'change' \ or not request.data: - return redirect(url_for('admin.configuration')) + return '' # redirect(url_for('admin.configuration')) log.debug('%r', request.headers) log.debug('%r', request.data) diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 489bc6f5..3e00c9af 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -20,6 +20,8 @@ from __future__ import division, print_function, unicode_literals import os import json import shutil +import chardet +import ssl from flask import Response, stream_with_context from sqlalchemy import create_engine