diff --git a/cps/admin.py b/cps/admin.py index b2f740bc..86f94a02 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -42,6 +42,8 @@ from .helper import speaking_language, check_valid_domain, send_test_mail, reset from .gdriveutils import is_gdrive_ready, gdrive_support from .web import admin_required, render_title_template, before_request, unconfigured, login_required_if_no_ano +log = logger.create() + feature_support = { 'ldap': bool(services.ldap), 'goodreads': bool(services.goodreads_support), @@ -57,7 +59,8 @@ feature_support = { try: from .oauth_bb import oauth_check, oauthblueprints feature_support['oauth'] = True -except ImportError: +except ImportError as err: + log.debug('Cannot import Flask-Dance, login with Oauth will not work: %s', err) feature_support['oauth'] = False oauthblueprints = [] oauth_check = {} @@ -65,7 +68,7 @@ except ImportError: feature_support['gdrive'] = gdrive_support admi = Blueprint('admin', __name__) -log = logger.create() + @admi.route("/admin") diff --git a/cps/oauth.py b/cps/oauth.py index a0d36eb5..c2f98bbb 100644 --- a/cps/oauth.py +++ b/cps/oauth.py @@ -23,7 +23,16 @@ from flask import session try: from flask_dance.consumer.backend.sqla import SQLAlchemyBackend, first, _get_real_user from sqlalchemy.orm.exc import NoResultFound +except ImportError: + # fails on flask-dance >1.3, due to renaming + try: + from flask_dance.consumer.storage.sqla import SQLAlchemyStorage as SQLAlchemyBackend + from flask_dance.consumer.storage.sqla import first, _get_real_user + from sqlalchemy.orm.exc import NoResultFound + except ImportError: + pass +try: class OAuthBackend(SQLAlchemyBackend): """ Stores and retrieves OAuth tokens using a relational database through @@ -152,5 +161,5 @@ try: blueprint=blueprint, user=user, user_id=user_id, )) -except ImportError: +except Exception: pass diff --git a/cps/services/__init__.py b/cps/services/__init__.py index 11ef4c65..17f1f529 100644 --- a/cps/services/__init__.py +++ b/cps/services/__init__.py @@ -26,7 +26,7 @@ log = logger.create() try: from . import goodreads_support except ImportError as err: - log.debug("cannot import goodreads, showing authors-metadata will not work: %s", err) + log.debug("Cannot import goodreads, showing authors-metadata will not work: %s", err) goodreads_support = None @@ -34,7 +34,7 @@ try: from . import simpleldap as ldap from .simpleldap import ldapVersion except ImportError as err: - log.debug("cannot import simpleldap, logging in with ldap will not work: %s", err) + log.debug("Cannot import simpleldap, logging in with ldap will not work: %s", err) ldap = None ldapVersion = None @@ -42,6 +42,6 @@ try: from . import SyncToken as SyncToken kobo = True except ImportError as err: - log.debug("cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err) + log.debug("Cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err) kobo = None SyncToken = None diff --git a/cps/ub.py b/cps/ub.py index 13e996cc..9a405d04 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -30,7 +30,12 @@ try: from flask_dance.consumer.backend.sqla import OAuthConsumerMixin oauth_support = True except ImportError: - oauth_support = False + # fails on flask-dance >1.3, due to renaming + try: + from flask_dance.consumer.storage.sqla import OAuthConsumerMixin + oauth_support = True + except ImportError: + oauth_support = False from sqlalchemy import create_engine, exc, exists from sqlalchemy import Column, ForeignKey from sqlalchemy import String, Integer, SmallInteger, Boolean, DateTime diff --git a/optional-requirements.txt b/optional-requirements.txt index 5504153c..fd40ca9d 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -1,16 +1,16 @@ # GDrive Integration google-api-python-client==1.7.11,<1.8.0 -gevent>=1.2.1,<1.5.0 +gevent>=1.2.1,<1.6.0 greenlet>=0.4.12,<0.5.0 httplib2>=0.9.2,<0.18.0 oauth2client>=4.0.0,<4.14.0 uritemplate>=3.0.0,<3.1.0 pyasn1-modules>=0.0.8,<0.3.0 pyasn1>=0.1.9,<0.5.0 -PyDrive>=1.3.1,<1.14.0 +PyDrive>=1.3.1,<1.4.0 PyYAML>=3.12 rsa==3.4.2,<4.1.0 -six>=1.10.0,<1.14.0 +six>=1.10.0,<1.15.0 # goodreads goodreads>=0.3.2,<0.4.0 @@ -21,12 +21,12 @@ python_ldap>=3.0.0,<3.3.0 flask-simpleldap>1.3.0,<1.5.0 #oauth -flask-dance>=0.13.0,<1.4.0 +flask-dance>=1.4.0,<3.1.0 sqlalchemy_utils>=0.33.5,<0.37.0 # extracting metadata lxml>=3.8.0,<4.6.0 -Pillow>=4.0.0,<7.1.0 +Pillow>=4.0.0,<7.2.0 rarfile>=2.7 # other diff --git a/requirements.txt b/requirements.txt index bec3a1d4..e7735041 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ Babel>=1.3, <2.9 Flask-Babel>=0.11.1,<1.1.0 Flask-Login>=0.3.2,<0.5.1 -Flask-Principal>=0.3.2,<0.5.0 +Flask-Principal>=0.3.2,<0.5.1 singledispatch>=3.4.0.0,<3.5.0.0 backports_abc>=0.4 Flask>=1.0.2,<1.2.0 iso-639>=0.4.5,<0.5.0 PyPDF2==1.26.0,<1.27.0 pytz>=2016.10 -requests>=2.11.1,<2.23.0 +requests>=2.11.1,<2.24.0 SQLAlchemy>=1.1.0,<1.4.0 tornado>=4.1,<6.1 Wand>=0.4.4,<0.6.0