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:
parent
25b09a532f
commit
27e8fbd248
34
cps/about.py
34
cps/about.py
@ -33,8 +33,9 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
flaskwtf_version = _(u'not installed')
|
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
|
from .render_template import render_title_template
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from flask_login import __version__ as flask_loginVersion
|
from flask_login import __version__ as flask_loginVersion
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -67,8 +68,14 @@ from . import services
|
|||||||
|
|
||||||
about = flask.Blueprint('about', __name__)
|
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()),
|
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
||||||
Python=sys.version,
|
Python=sys.version,
|
||||||
Calibre_Web=constants.STABLE_VERSION['version'] + ' - '
|
Calibre_Web=constants.STABLE_VERSION['version'] + ' - '
|
||||||
@ -96,9 +103,24 @@ _VERSIONS = OrderedDict(
|
|||||||
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
||||||
flask_dance=flask_danceVersion,
|
flask_dance=flask_danceVersion,
|
||||||
greenlet=greenlet_Version
|
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():
|
def collect_stats():
|
||||||
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
|
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
|
||||||
@ -115,5 +137,3 @@ def stats():
|
|||||||
series = calibre_db.session.query(db.Series).count()
|
series = calibre_db.session.query(db.Series).count()
|
||||||
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
|
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
|
||||||
categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat")
|
categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat")
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,15 +18,14 @@ if not importlib:
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
pkgresources = False
|
pkgresources = False
|
||||||
|
|
||||||
def dependency_check(optional=False):
|
def load_dependencys(optional=False):
|
||||||
dep = list()
|
deps = list()
|
||||||
if importlib or pkgresources:
|
if importlib or pkgresources:
|
||||||
if optional:
|
if optional:
|
||||||
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
req_path = os.path.join(BASE_DIR, "optional-requirements.txt")
|
||||||
else:
|
else:
|
||||||
req_path = os.path.join(BASE_DIR, "requirements.txt")
|
req_path = os.path.join(BASE_DIR, "requirements.txt")
|
||||||
if os.path.exists(req_path):
|
if os.path.exists(req_path):
|
||||||
try:
|
|
||||||
with open(req_path, 'r') as f:
|
with open(req_path, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
|
if not line.startswith('#') and not line == '\n' and not line.startswith('git'):
|
||||||
@ -39,45 +38,56 @@ def dependency_check(optional=False):
|
|||||||
except ImportNotFound:
|
except ImportNotFound:
|
||||||
if optional:
|
if optional:
|
||||||
continue
|
continue
|
||||||
else:
|
'''else:
|
||||||
return [{'name':res.group(1),
|
return [{'name':res.group(1),
|
||||||
'target': "available",
|
'target': "available",
|
||||||
'found': "Not 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('.'):
|
def dependency_check(optional=False):
|
||||||
dep.append({'name': res.group(1),
|
d = list()
|
||||||
'found': dep_version,
|
deps = load_dependencys(optional)
|
||||||
"target": res.group(2) + res.group(3)})
|
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
|
continue
|
||||||
elif res.group(2).strip() == ">=":
|
elif dep[2].strip() == ">=":
|
||||||
if dep_version.split('.') < res.group(3).split('.'):
|
if dep_version_int < low_check:
|
||||||
dep.append({'name': res.group(1),
|
d.append({'name': dep[1],
|
||||||
'found': dep_version,
|
'found': dep[0],
|
||||||
"target": res.group(2) + res.group(3)})
|
"target": dep[2] + dep[3]})
|
||||||
continue
|
continue
|
||||||
elif res.group(2).strip() == ">":
|
elif dep[2].strip() == ">":
|
||||||
if dep_version.split('.') <= res.group(3).split('.'):
|
if dep_version_int <= low_check:
|
||||||
dep.append({'name': res.group(1),
|
d.append({'name': dep[1],
|
||||||
'found': dep_version,
|
'found': dep[0],
|
||||||
"target": res.group(2) + res.group(3)})
|
"target": dep[2] + dep[3]})
|
||||||
continue
|
continue
|
||||||
if res.group(4) and res.group(5):
|
if dep[4] and dep[5]:
|
||||||
if res.group(4).strip() == "<":
|
if dep[4].strip() == "<":
|
||||||
if dep_version.split('.') >= res.group(5).split('.'):
|
if dep_version_int >= high_check:
|
||||||
dep.append(
|
d.append(
|
||||||
{'name': res.group(1),
|
{'name': dep[1],
|
||||||
'found': dep_version,
|
'found': dep[0],
|
||||||
"target": res.group(4) + res.group(5)})
|
"target": dep[4] + dep[5]})
|
||||||
continue
|
continue
|
||||||
elif res.group(2).strip() == "<=":
|
elif dep[4].strip() == "<=":
|
||||||
if dep_version.split('.') > res.group(5).split('.'):
|
if dep_version_int > high_check:
|
||||||
dep.append(
|
d.append(
|
||||||
{'name': res.group(1),
|
{'name': dep[1],
|
||||||
'found': dep_version,
|
'found': dep[0],
|
||||||
"target": res.group(4) + res.group(5)})
|
"target": dep[4] + dep[5]})
|
||||||
continue
|
continue
|
||||||
except Exception as e:
|
return d
|
||||||
print(e)
|
|
||||||
return dep
|
|
||||||
|
@ -114,7 +114,7 @@ def search_objects_add(db_book_object, db_type, input_elements):
|
|||||||
type_elements = c_elements.value
|
type_elements = c_elements.value
|
||||||
else:
|
else:
|
||||||
type_elements = c_elements.name
|
type_elements = c_elements.name
|
||||||
if inp_element == type_elements:
|
if inp_element.lower() == type_elements.lower(): # Lowercase check
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
|
@ -35,6 +35,15 @@ except ImportError:
|
|||||||
from sqlalchemy.exc import OperationalError, InvalidRequestError
|
from sqlalchemy.exc import OperationalError, InvalidRequestError
|
||||||
from sqlalchemy.sql.expression import text
|
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:
|
try:
|
||||||
from apiclient import errors
|
from apiclient import errors
|
||||||
from httplib2 import ServerNotFoundError
|
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'
|
return 'Callback url (redirect url) is missing in client_secrets.json'
|
||||||
if client_secrets:
|
if client_secrets:
|
||||||
client_secrets.update(filedata['web'])
|
client_secrets.update(filedata['web'])
|
||||||
|
|
||||||
|
|
||||||
|
def get_versions():
|
||||||
|
return {'six': six_version,
|
||||||
|
'httplib2': httplib2_version}
|
||||||
|
@ -274,31 +274,30 @@ def pdf_preview(tmp_file_path, tmp_dir):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_versions():
|
def get_versions(all=True):
|
||||||
|
ret = dict()
|
||||||
if not use_generic_pdf_cover:
|
if not use_generic_pdf_cover:
|
||||||
IVersion = ImageVersion.MAGICK_VERSION
|
ret['Image Magick'] = ImageVersion.MAGICK_VERSION
|
||||||
WVersion = ImageVersion.VERSION
|
|
||||||
else:
|
else:
|
||||||
IVersion = u'not installed'
|
ret['Image Magick'] = u'not installed'
|
||||||
WVersion = 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:
|
if use_pdf_meta:
|
||||||
PVersion='v'+PyPdfVersion
|
ret['PyPdf'] = PyPdfVersion
|
||||||
else:
|
else:
|
||||||
PVersion=u'not installed'
|
ret['PyPdf'] = u'not installed'
|
||||||
if lxmlversion:
|
if lxmlversion:
|
||||||
XVersion = 'v'+'.'.join(map(str, lxmlversion))
|
ret['lxml'] = '.'.join(map(str, lxmlversion))
|
||||||
else:
|
else:
|
||||||
XVersion = u'not installed'
|
ret['lxml'] = u'not installed'
|
||||||
if comic.use_comic_meta:
|
if comic.use_comic_meta:
|
||||||
ComicVersion = comic.comic_version or u'installed'
|
ret['Comic_API'] = comic.comic_version or u'installed'
|
||||||
else:
|
else:
|
||||||
ComicVersion = u'not installed'
|
ret['Comic_API'] = u'not installed'
|
||||||
return {'Image Magick': IVersion,
|
return ret
|
||||||
'PyPdf': PVersion,
|
|
||||||
'lxml':XVersion,
|
|
||||||
'Wand': WVersion,
|
|
||||||
# 'Pillow': PILVersion,
|
|
||||||
'Comic_API': ComicVersion}
|
|
||||||
|
|
||||||
|
|
||||||
def upload(uploadfile, rarExcecutable):
|
def upload(uploadfile, rarExcecutable):
|
||||||
|
Loading…
Reference in New Issue
Block a user