Skip to content

Commit

Permalink
Merge branch 'master' into Develop
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzieIsaacs committed Jan 31, 2022
2 parents 4dcc448 + 95e0255 commit 61bfeae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
36 changes: 19 additions & 17 deletions cps/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@
import sqlite3
from collections import OrderedDict

import babel, pytz, requests, sqlalchemy
import werkzeug, flask, flask_login, flask_principal, jinja2
import babel
import pytz
import requests
import sqlalchemy
import werkzeug
import flask
import flask_login
import flask_principal
import jinja2
from flask_babel import gettext as _
try:
from flask_wtf import __version__ as flaskwtf_version
Expand Down Expand Up @@ -58,12 +65,6 @@
except ImportError:
greenlet_Version = None

try:
from scholarly import scholarly
scholarly_version = _(u'installed')
except ImportError:
scholarly_version = _(u'not installed')

from . import services

about = flask.Blueprint('about', __name__)
Expand All @@ -78,16 +79,16 @@
calibre_web_version = constants.STABLE_VERSION['version']
else:
calibre_web_version = (constants.STABLE_VERSION['version'] + ' - '
+ constants.NIGHTLY_VERSION[0].replace('%','%%') + ' - '
+ constants.NIGHTLY_VERSION[1].replace('%','%%'))
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
if getattr(sys, 'frozen', False):
calibre_web_version += " - Exe-Version"
elif constants.HOME_CONFIG:
calibre_web_version += " - pyPi"

if not ret:
_VERSIONS = OrderedDict(
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
Python=sys.version,
Calibre_Web=calibre_web_version,
WebServer=server.VERSION,
Expand All @@ -105,7 +106,6 @@
iso639=isoLanguages.__version__,
pytz=pytz.__version__,
Unidecode=unidecode_version,
Scholarly=scholarly_version,
Flask_SimpleLDAP=u'installed' if bool(services.ldap) else None,
python_LDAP=services.ldapVersion if bool(services.ldapVersion) else None,
Goodreads=u'installed' if bool(services.goodreads_support) else None,
Expand All @@ -117,23 +117,25 @@
_VERSIONS.update(uploader.get_versions(True))
else:
_VERSIONS = OrderedDict(
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
Python = sys.version,
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
Python=sys.version,
Calibre_Web=calibre_web_version,
Werkzeug = werkzeug.__version__,
Werkzeug=werkzeug.__version__,
Jinja2=jinja2.__version__,
pySqlite = sqlite3.version,
SQLite = sqlite3.sqlite_version,
pySqlite=sqlite3.version,
SQLite=sqlite3.sqlite_version,
)
_VERSIONS.update(ret)
_VERSIONS.update(uploader.get_versions(False))


def collect_stats():
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
_VERSIONS['unrar'] = _(converter.get_unrar_version())
_VERSIONS['kepubify'] = _(converter.get_kepubify_version())
return _VERSIONS


@about.route("/stats")
@flask_login.login_required
def stats():
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 @@ -19,7 +19,14 @@
from typing import Dict, List, Optional
from urllib.parse import quote

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 MetaRecord, MetaSourceInfo, Metadata

Expand Down

0 comments on commit 61bfeae

Please sign in to comment.