diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 489bc6f5..1c5dec05 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -89,7 +89,7 @@ class Singleton: except AttributeError: self._instance = self._decorated() return self._instance - except ImportError as e: + except (ImportError, NameError) as e: log.debug(e) return None diff --git a/cps/oauth_bb.py b/cps/oauth_bb.py index 000a7376..620ff10e 100644 --- a/cps/oauth_bb.py +++ b/cps/oauth_bb.py @@ -100,25 +100,26 @@ def logout_oauth_user(): if ub.oauth_support: oauthblueprints = [] - if not g.ubsession.query(ub.OAuthProvider).count(): + oauth_session = ub.Scoped_Session() + if not oauth_session.query(ub.OAuthProvider).count(): oauthProvider = ub.OAuthProvider() oauthProvider.provider_name = "github" oauthProvider.active = False - g.ubsession.add(oauthProvider) + oauth_session.add(oauthProvider) try: - g.ubsession.commit() + oauth_session.commit() except OperationalError: - g.ubsession.rollback() + oauth_session.rollback() oauthProvider = ub.OAuthProvider() oauthProvider.provider_name = "google" oauthProvider.active = False - g.ubsession.add(oauthProvider) + oauth_session.add(oauthProvider) try: - g.ubsession.commit() + oauth_session.commit() except OperationalError: - g.ubsession.rollback() + oauth_session.rollback() - oauth_ids = g.ubsession.query(ub.OAuthProvider).all() + oauth_ids = oauth_session.query(ub.OAuthProvider).all() ele1 = dict(provider_name='github', id=oauth_ids[0].id, active=oauth_ids[0].active, @@ -148,7 +149,7 @@ if ub.oauth_support: scope=element['scope'] ) element['blueprint'] = blueprint - element['blueprint'].backend = OAuthBackend(ub.OAuth, g.ubsession, str(element['id']), + element['blueprint'].backend = OAuthBackend(ub.OAuth, oauth_session, str(element['id']), user=current_user, user_required=True) app.register_blueprint(blueprint, url_prefix="/login") if element['active']: @@ -192,7 +193,7 @@ if ub.oauth_support: session[provider_id + "_oauth_token"] = token # Find this OAuth token in the database, or create it - query = g.ubsession.query(ub.OAuth).filter_by( + query = oauth_session.query(ub.OAuth).filter_by( provider=provider_id, provider_user_id=provider_user_id, ) @@ -207,11 +208,11 @@ if ub.oauth_support: token=token, ) try: - g.ubsession.add(oauth_entry) - g.ubsession.commit() + oauth_session.add(oauth_entry) + oauth_session.commit() except Exception as e: log.exception(e) - g.ubsession.rollback() + oauth_session.rollback() # Disable Flask-Dance's default behavior for saving the OAuth token # Value differrs depending on flask-dance version diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index e96fa1ac..4133a3ff 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2020-12-02 15:51:36

+

Start Time: 2020-12-08 08:19:58

-

Stop Time: 2020-12-02 18:01:04

+

Stop Time: 2020-12-08 10:00:52

-

Duration: 1h 41 min

+

Duration: 1h 15 min

@@ -511,162 +511,730 @@ AssertionError: False is not true : BMP file is not detected - + TestEbookConvertCalibreGDrive - 6 - 6 + 12 0 0 + 12 0 - Detail + Detail - +
TestEbookConvertCalibreGDrive - test_convert_email
- PASS + +
+ ERROR +
+ + + + - + -
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
+
TestEbookConvertCalibreGDrive - test_convert_email
+ + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertCalibreGDrive - test_convert_only
+
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
+ + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertCalibreGDrive - test_convert_parameter
+
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
+ + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertCalibreGDrive - test_email_failed
+
TestEbookConvertCalibreGDrive - test_convert_only
+ + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertCalibreGDrive - test_email_only
+
TestEbookConvertCalibreGDrive - test_convert_only
- PASS - - - + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertKepubify - test_convert_only
+
TestEbookConvertCalibreGDrive - test_convert_parameter
+ + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertKepubify - test_convert_wrong_excecutable
+
TestEbookConvertCalibreGDrive - test_convert_parameter
- PASS - - - + +
+ ERROR +
+ + + - PASS - + -
TestEbookConvertGDriveKepubify - test_convert_only
+
TestEbookConvertCalibreGDrive - test_email_failed
- FAIL + ERROR
-