Fix for #2299 (scholarly requires Internet connection at startup)

This commit is contained in:
Ozzie Isaacs 2022-01-31 18:09:23 +01:00
parent 42f8209a4a
commit 23e47ba4e6
3 changed files with 13 additions and 9 deletions

View File

@ -58,10 +58,14 @@ try:
except ImportError:
greenlet_Version = None
try:
from fake_useragent.errors import FakeUserAgentError
except (ImportError):
FakeUserAgentError = BaseException
try:
from scholarly import scholarly
scholarly_version = _(u'installed')
except ImportError:
except (ImportError, FakeUserAgentError):
scholarly_version = _(u'not installed')
from . import services

View File

@ -33,13 +33,6 @@ try:
except ImportError:
pass
# Improve this to check if scholarly is available in a global way, like other pythonic libraries
try:
from scholarly import scholarly
have_scholar = True
except ImportError:
have_scholar = False
from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response
from flask_babel import gettext as _
from flask_login import current_user, login_required

View File

@ -16,7 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from scholarly import scholarly
try:
from fake_useragent.errors import FakeUserAgentError
except (ImportError):
FakeUserAgentError = BaseException
try:
from scholarly import scholarly
except FakeUserAgentError:
raise ImportError("No module named 'scholarly'")
from cps.services.Metadata import Metadata