diff --git a/cps.py b/cps.py
index 21c9c7af..c36ed0fc 100755
--- a/cps.py
+++ b/cps.py
@@ -36,7 +36,11 @@ from cps.shelf import shelf
from cps.admin import admi
from cps.gdrive import gdrive
from cps.editbooks import editbook
-from cps.oauth_bb import oauth
+try:
+ from cps.oauth_bb import oauth
+ oauth_available = True
+except ImportError:
+ oauth_available = False
if __name__ == '__main__':
@@ -49,7 +53,8 @@ if __name__ == '__main__':
app.register_blueprint(admi)
app.register_blueprint(gdrive)
app.register_blueprint(editbook)
- app.register_blueprint(oauth)
+ if oauth_available:
+ app.register_blueprint(oauth)
Server.startServer()
diff --git a/cps/about.py b/cps/about.py
index 6e82b964..69deb7db 100644
--- a/cps/about.py
+++ b/cps/about.py
@@ -23,7 +23,7 @@
from flask import Blueprint
from flask_login import login_required
-import db
+from cps import db
import sys
import uploader
from babel import __version__ as babelVersion
diff --git a/cps/editbooks.py b/cps/editbooks.py
index c758bb18..c96ec942 100644
--- a/cps/editbooks.py
+++ b/cps/editbooks.py
@@ -26,7 +26,7 @@ from cps import config, language_table, get_locale, app, ub, global_WorkerThread
from flask import request, flash, redirect, url_for, abort, Markup, Response
from flask import Blueprint
import datetime
-import db
+from cps import db
import os
import json
from flask_babel import gettext as _
diff --git a/cps/helper.py b/cps/helper.py
index d780620b..1175f9f0 100644
--- a/cps/helper.py
+++ b/cps/helper.py
@@ -19,13 +19,12 @@
# along with this program. If not, see .
-from cps import config, global_WorkerThread, get_locale
+from cps import config, global_WorkerThread, get_locale, db
from flask import current_app as app
from tempfile import gettempdir
import sys
import os
import re
-import db
import unicodedata
import worker
import time
diff --git a/cps/opds.py b/cps/opds.py
index 419cdea2..d73bc4e2 100644
--- a/cps/opds.py
+++ b/cps/opds.py
@@ -22,12 +22,11 @@
# along with this program. If not, see .
# opds routing functions
-from cps import config, mimetypes, app
+from cps import config, mimetypes, app, db
from flask import request, render_template, Response, g, make_response
from pagination import Pagination
from flask import Blueprint
import datetime
-import db
import ub
from flask_login import current_user
from functools import wraps
diff --git a/cps/shelf.py b/cps/shelf.py
index 34d8eb47..109eff75 100644
--- a/cps/shelf.py
+++ b/cps/shelf.py
@@ -22,13 +22,11 @@
# along with this program. If not, see .
from flask import Blueprint, request, flash, redirect, url_for
-from cps import ub, searched_ids
+from cps import ub, searched_ids, app, db
from flask_babel import gettext as _
from sqlalchemy.sql.expression import func, or_
from flask_login import login_required, current_user
from web import render_title_template
-from cps import app
-import db
shelf = Blueprint('shelf', __name__)
diff --git a/cps/web.py b/cps/web.py
index c9720505..5eea12bd 100644
--- a/cps/web.py
+++ b/cps/web.py
@@ -40,10 +40,9 @@ import json
import datetime
from iso639 import languages as isoLanguages
import re
-import db
import gdriveutils
from redirect import redirect_back
-from cps import lm, babel, ub, config, get_locale, language_table, app
+from cps import lm, babel, ub, config, get_locale, language_table, app, db
from pagination import Pagination
from sqlalchemy.sql.expression import text