Skip to content

Commit

Permalink
Fix for janeczku#2299 (scholarly requires Internet connection at star…
Browse files Browse the repository at this point in the history
…tup)
  • Loading branch information
OzzieIsaacs committed Jan 31, 2022
1 parent 42f8209 commit 23e47ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion cps/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@
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
Expand Down
7 changes: 0 additions & 7 deletions cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
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
Expand Down
9 changes: 8 additions & 1 deletion cps/metadata_provider/scholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 23e47ba

Please sign in to comment.