1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-24 18:47:23 +00:00

Show dependencies in about section from automatic dependency check

Bugfix and refactored dependency check
Added output of googledrive dependencies as fallback option
This commit is contained in:
Ozzieisaacs 2021-11-06 20:17:00 +04:00
parent 25b09a532f
commit 27e8fbd248
5 changed files with 162 additions and 119 deletions

View File

@ -33,8 +33,9 @@ try:
except ImportError:
flaskwtf_version = _(u'not installed')
from . import db, calibre_db, converter, uploader, server, isoLanguages, constants
from . import db, calibre_db, converter, uploader, server, isoLanguages, constants, gdriveutils, dep_check
from .render_template import render_title_template
try:
from flask_login import __version__ as flask_loginVersion
except ImportError:
@ -67,8 +68,14 @@ from . import services
about = flask.Blueprint('about', __name__)
ret = dict()
req = dep_check.load_dependencys(False)
opt = dep_check.load_dependencys(True)
for i in (req + opt):
ret[i[1]] = i[0]
_VERSIONS = OrderedDict(
if not ret:
_VERSIONS = OrderedDict(
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
Python=sys.version,
Calibre_Web=constants.STABLE_VERSION['version'] + ' - '
@ -96,9 +103,24 @@ _VERSIONS = OrderedDict(
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
flask_dance=flask_danceVersion,
greenlet=greenlet_Version
)
_VERSIONS.update(uploader.get_versions())
)
_VERSIONS.update(gdriveutils.get_versions())
_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,
Calibre_Web = constants.STABLE_VERSION['version'] + ' - '
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'),
Werkzeug = werkzeug.__version__,
Jinja2=jinja2.__version__,
pySqlite = sqlite3.version,
SQLite = sqlite3.sqlite_version,
Unidecode=unidecode_version,
)
_VERSIONS.update(ret)
_VERSIONS.update(uploader.get_versions(False))
def collect_stats():
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
@ -115,5 +137,3 @@ def stats():
series = calibre_db.session.query(db.Series).count()
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat")

View File

@ -18,15 +18,14 @@ if not importlib:
except ImportError as e:
pkgresources = False
def dependency_check(optional=False):
dep = list()
def load_dependencys(optional=False):
deps = list()
if importlib or pkgresources:
if optional:
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
else:
req_path = os.path.join(BASE_DIR, "requirements.txt")
if os.path.exists(req_path):
try:
with open(req_path, 'r') as f:
for line in f:
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
@ -39,45 +38,56 @@ def dependency_check(optional=False):
except ImportNotFound:
if optional:
continue
else:
'''else:
return [{'name':res.group(1),
'target': "available",
'found': "Not available"
}]
}]'''
deps.append([dep_version, res.group(1), res.group(2), res.group(3), res.group(4), res.group(5)])
return deps
if res.group(2).strip() == "==":
if dep_version.split('.') != res.group(3).split('.'):
dep.append({'name': res.group(1),
'found': dep_version,
"target": res.group(2) + res.group(3)})
def dependency_check(optional=False):
d = list()
deps = load_dependencys(optional)
for dep in deps:
dep_version_int = [int(x) for x in dep[0].split('.')]
low_check = [int(x) for x in dep[3].split('.')]
try:
high_check = [int(x) for x in dep[5].split('.')]
except AttributeError:
high_check = None
if dep[2].strip() == "==":
if dep_version_int != low_check:
d.append({'name': dep[1],
'found': dep[0],
"target": dep[2] + dep[3]})
continue
elif res.group(2).strip() == ">=":
if dep_version.split('.') < res.group(3).split('.'):
dep.append({'name': res.group(1),
'found': dep_version,
"target": res.group(2) + res.group(3)})
elif dep[2].strip() == ">=":
if dep_version_int < low_check:
d.append({'name': dep[1],
'found': dep[0],
"target": dep[2] + dep[3]})
continue
elif res.group(2).strip() == ">":
if dep_version.split('.') <= res.group(3).split('.'):
dep.append({'name': res.group(1),
'found': dep_version,
"target": res.group(2) + res.group(3)})
elif dep[2].strip() == ">":
if dep_version_int <= low_check:
d.append({'name': dep[1],
'found': dep[0],
"target": dep[2] + dep[3]})
continue
if res.group(4) and res.group(5):
if res.group(4).strip() == "<":
if dep_version.split('.') >= res.group(5).split('.'):
dep.append(
{'name': res.group(1),
'found': dep_version,
"target": res.group(4) + res.group(5)})
if dep[4] and dep[5]:
if dep[4].strip() == "<":
if dep_version_int >= high_check:
d.append(
{'name': dep[1],
'found': dep[0],
"target": dep[4] + dep[5]})
continue
elif res.group(2).strip() == "<=":
if dep_version.split('.') > res.group(5).split('.'):
dep.append(
{'name': res.group(1),
'found': dep_version,
"target": res.group(4) + res.group(5)})
elif dep[4].strip() == "<=":
if dep_version_int > high_check:
d.append(
{'name': dep[1],
'found': dep[0],
"target": dep[4] + dep[5]})
continue
except Exception as e:
print(e)
return dep
return d

View File

@ -114,7 +114,7 @@ def search_objects_add(db_book_object, db_type, input_elements):
type_elements = c_elements.value
else:
type_elements = c_elements.name
if inp_element == type_elements:
if inp_element.lower() == type_elements.lower(): # Lowercase check
found = True
break
if not found:

View File

@ -35,6 +35,15 @@ except ImportError:
from sqlalchemy.exc import OperationalError, InvalidRequestError
from sqlalchemy.sql.expression import text
try:
from six import __version__ as six_version
except ImportError:
six_version = "not installed"
try:
from httplib2 import __version__ as httplib2_version
except ImportError:
httplib2_version = "not installed"
try:
from apiclient import errors
from httplib2 import ServerNotFoundError
@ -659,3 +668,8 @@ def get_error_text(client_secrets=None):
return 'Callback url (redirect url) is missing in client_secrets.json'
if client_secrets:
client_secrets.update(filedata['web'])
def get_versions():
return {'six': six_version,
'httplib2': httplib2_version}

View File

@ -274,31 +274,30 @@ def pdf_preview(tmp_file_path, tmp_dir):
return None
def get_versions():
def get_versions(all=True):
ret = dict()
if not use_generic_pdf_cover:
IVersion = ImageVersion.MAGICK_VERSION
WVersion = ImageVersion.VERSION
ret['Image Magick'] = ImageVersion.MAGICK_VERSION
else:
IVersion = u'not installed'
WVersion = u'not installed'
ret['Image Magick'] = u'not installed'
if all:
if not use_generic_pdf_cover:
ret['Wand'] = ImageVersion.VERSION
else:
ret['Wand'] = u'not installed'
if use_pdf_meta:
PVersion='v'+PyPdfVersion
ret['PyPdf'] = PyPdfVersion
else:
PVersion=u'not installed'
ret['PyPdf'] = u'not installed'
if lxmlversion:
XVersion = 'v'+'.'.join(map(str, lxmlversion))
ret['lxml'] = '.'.join(map(str, lxmlversion))
else:
XVersion = u'not installed'
ret['lxml'] = u'not installed'
if comic.use_comic_meta:
ComicVersion = comic.comic_version or u'installed'
ret['Comic_API'] = comic.comic_version or u'installed'
else:
ComicVersion = u'not installed'
return {'Image Magick': IVersion,
'PyPdf': PVersion,
'lxml':XVersion,
'Wand': WVersion,
# 'Pillow': PILVersion,
'Comic_API': ComicVersion}
ret['Comic_API'] = u'not installed'
return ret
def upload(uploadfile, rarExcecutable):