mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-19 14:40:30 +00:00
Merge branch 'master' of https://github.com/janeczku/calibre-web
This commit is contained in:
commit
294c594cbb
@ -129,7 +129,7 @@ def create_app():
|
|||||||
web_server.stop(True)
|
web_server.stop(True)
|
||||||
sys.exit(7)
|
sys.exit(7)
|
||||||
for res in dependency_check() + dependency_check(True):
|
for res in dependency_check() + dependency_check(True):
|
||||||
log.info('*** "{}" version does not fit the requirements. Should: {}, Found: {}, please consider updating. ***'
|
log.info('*** "{}" version does not fit the requirements. Should: {}, Found: {}, please consider installing required version ***'
|
||||||
.format(res['name'],
|
.format(res['name'],
|
||||||
res['target'],
|
res['target'],
|
||||||
res['found']))
|
res['found']))
|
||||||
|
87
cps/about.py
87
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,38 +68,58 @@ 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:
|
||||||
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
_VERSIONS = OrderedDict(
|
||||||
Python=sys.version,
|
Platform = '{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
||||||
Calibre_Web=constants.STABLE_VERSION['version'] + ' - '
|
Python=sys.version,
|
||||||
+ constants.NIGHTLY_VERSION[0].replace('%','%%') + ' - '
|
Calibre_Web=constants.STABLE_VERSION['version'] + ' - '
|
||||||
+ constants.NIGHTLY_VERSION[1].replace('%','%%'),
|
+ constants.NIGHTLY_VERSION[0].replace('%','%%') + ' - '
|
||||||
WebServer=server.VERSION,
|
+ constants.NIGHTLY_VERSION[1].replace('%','%%'),
|
||||||
Flask=flask.__version__,
|
WebServer=server.VERSION,
|
||||||
Flask_Login=flask_loginVersion,
|
Flask=flask.__version__,
|
||||||
Flask_Principal=flask_principal.__version__,
|
Flask_Login=flask_loginVersion,
|
||||||
Flask_WTF=flaskwtf_version,
|
Flask_Principal=flask_principal.__version__,
|
||||||
Werkzeug=werkzeug.__version__,
|
Flask_WTF=flaskwtf_version,
|
||||||
Babel=babel.__version__,
|
Werkzeug=werkzeug.__version__,
|
||||||
Jinja2=jinja2.__version__,
|
Babel=babel.__version__,
|
||||||
Requests=requests.__version__,
|
Jinja2=jinja2.__version__,
|
||||||
SqlAlchemy=sqlalchemy.__version__,
|
Requests=requests.__version__,
|
||||||
pySqlite=sqlite3.version,
|
SqlAlchemy=sqlalchemy.__version__,
|
||||||
SQLite=sqlite3.sqlite_version,
|
pySqlite=sqlite3.version,
|
||||||
iso639=isoLanguages.__version__,
|
SQLite=sqlite3.sqlite_version,
|
||||||
pytz=pytz.__version__,
|
iso639=isoLanguages.__version__,
|
||||||
Unidecode=unidecode_version,
|
pytz=pytz.__version__,
|
||||||
Scholarly=scholarly_version,
|
Unidecode=unidecode_version,
|
||||||
Flask_SimpleLDAP=u'installed' if bool(services.ldap) else None,
|
Scholarly=scholarly_version,
|
||||||
python_LDAP=services.ldapVersion if bool(services.ldapVersion) else None,
|
Flask_SimpleLDAP=u'installed' if bool(services.ldap) else None,
|
||||||
Goodreads=u'installed' if bool(services.goodreads_support) else None,
|
python_LDAP=services.ldapVersion if bool(services.ldapVersion) else None,
|
||||||
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
Goodreads=u'installed' if bool(services.goodreads_support) else None,
|
||||||
flask_dance=flask_danceVersion,
|
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
||||||
greenlet=greenlet_Version
|
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,
|
||||||
|
)
|
||||||
|
_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 +136,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")
|
||||||
|
|
||||||
|
|
||||||
|
125
cps/dep_check.py
125
cps/dep_check.py
@ -18,66 +18,79 @@ 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'):
|
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
||||||
res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?', line.strip())
|
try:
|
||||||
try:
|
if importlib:
|
||||||
if importlib:
|
dep_version = version(res.group(1))
|
||||||
dep_version = version(res.group(1))
|
else:
|
||||||
else:
|
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
||||||
dep_version = pkg_resources.get_distribution(res.group(1)).version
|
except ImportNotFound:
|
||||||
except ImportNotFound:
|
if optional:
|
||||||
if optional:
|
continue
|
||||||
continue
|
dep_version = "not installed"
|
||||||
else:
|
deps.append([dep_version, res.group(1), res.group(2), res.group(3), res.group(4), res.group(5)])
|
||||||
return [{'name':res.group(1),
|
return deps
|
||||||
'target': "available",
|
|
||||||
'found': "Not available"
|
|
||||||
}]
|
|
||||||
|
|
||||||
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:
|
||||||
continue
|
try:
|
||||||
elif res.group(2).strip() == ">=":
|
dep_version_int = [int(x) for x in dep[0].split('.')]
|
||||||
if dep_version.split('.') < res.group(3).split('.'):
|
low_check = [int(x) for x in dep[3].split('.')]
|
||||||
dep.append({'name': res.group(1),
|
high_check = [int(x) for x in dep[5].split('.')]
|
||||||
'found': dep_version,
|
except AttributeError:
|
||||||
"target": res.group(2) + res.group(3)})
|
high_check = None
|
||||||
continue
|
except ValueError:
|
||||||
elif res.group(2).strip() == ">":
|
d.append({'name': dep[1],
|
||||||
if dep_version.split('.') <= res.group(3).split('.'):
|
'target': "available",
|
||||||
dep.append({'name': res.group(1),
|
'found': "Not available"
|
||||||
'found': dep_version,
|
})
|
||||||
"target": res.group(2) + res.group(3)})
|
continue
|
||||||
continue
|
|
||||||
if res.group(4) and res.group(5):
|
if dep[2].strip() == "==":
|
||||||
if res.group(4).strip() == "<":
|
if dep_version_int != low_check:
|
||||||
if dep_version.split('.') >= res.group(5).split('.'):
|
d.append({'name': dep[1],
|
||||||
dep.append(
|
'found': dep[0],
|
||||||
{'name': res.group(1),
|
"target": dep[2] + dep[3]})
|
||||||
'found': dep_version,
|
continue
|
||||||
"target": res.group(4) + res.group(5)})
|
elif dep[2].strip() == ">=":
|
||||||
continue
|
if dep_version_int < low_check:
|
||||||
elif res.group(2).strip() == "<=":
|
d.append({'name': dep[1],
|
||||||
if dep_version.split('.') > res.group(5).split('.'):
|
'found': dep[0],
|
||||||
dep.append(
|
"target": dep[2] + dep[3]})
|
||||||
{'name': res.group(1),
|
continue
|
||||||
'found': dep_version,
|
elif dep[2].strip() == ">":
|
||||||
"target": res.group(4) + res.group(5)})
|
if dep_version_int <= low_check:
|
||||||
continue
|
d.append({'name': dep[1],
|
||||||
except Exception as e:
|
'found': dep[0],
|
||||||
print(e)
|
"target": dep[2] + dep[3]})
|
||||||
return dep
|
continue
|
||||||
|
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 dep[4].strip() == "<=":
|
||||||
|
if dep_version_int > high_check:
|
||||||
|
d.append(
|
||||||
|
{'name': dep[1],
|
||||||
|
'found': dep[0],
|
||||||
|
"target": dep[4] + dep[5]})
|
||||||
|
continue
|
||||||
|
return d
|
||||||
|
@ -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:
|
||||||
@ -503,7 +503,7 @@ def edit_book_languages(languages, book, upload=False, invalid=None):
|
|||||||
|
|
||||||
def edit_book_publisher(publishers, book):
|
def edit_book_publisher(publishers, book):
|
||||||
changed = False
|
changed = False
|
||||||
if publishers:
|
if publishers:
|
||||||
publisher = publishers.rstrip().strip()
|
publisher = publishers.rstrip().strip()
|
||||||
if len(book.publishers) == 0 or (len(book.publishers) > 0 and publisher != book.publishers[0].name):
|
if len(book.publishers) == 0 or (len(book.publishers) > 0 and publisher != book.publishers[0].name):
|
||||||
changed |= modify_database_object([publisher], book.publishers, db.Publishers, calibre_db.session,
|
changed |= modify_database_object([publisher], book.publishers, db.Publishers, calibre_db.session,
|
||||||
|
@ -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}
|
||||||
|
@ -157,7 +157,7 @@ def parse_xmp(pdf_file):
|
|||||||
|
|
||||||
def parse_xmp(pdf_file):
|
def parse_xmp(pdf_file):
|
||||||
"""
|
"""
|
||||||
Parse XMP Metadata and prepare for BookMeta object
|
Parse XMP Metadata and prepare for BookMeta object
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
xmp_info = pdf_file.getXmpMetadata()
|
xmp_info = pdf_file.getXmpMetadata()
|
||||||
@ -170,8 +170,8 @@ def parse_xmp(pdf_file):
|
|||||||
xmp_author = xmp_info.dc_creator # list
|
xmp_author = xmp_info.dc_creator # list
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
xmp_author = ['Unknown']
|
xmp_author = ['Unknown']
|
||||||
|
|
||||||
if xmp_info.dc_title:
|
if xmp_info.dc_title:
|
||||||
xmp_title = xmp_info.dc_title['x-default']
|
xmp_title = xmp_info.dc_title['x-default']
|
||||||
else:
|
else:
|
||||||
xmp_title = ''
|
xmp_title = ''
|
||||||
@ -187,7 +187,7 @@ def parse_xmp(pdf_file):
|
|||||||
languages.append(isoLanguages.get_lang3(i))
|
languages.append(isoLanguages.get_lang3(i))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
languages.append('')
|
languages.append('')
|
||||||
|
|
||||||
xmp_tags = ', '.join(xmp_info.dc_subject)
|
xmp_tags = ', '.join(xmp_info.dc_subject)
|
||||||
xmp_publisher = ', '.join(xmp_info.dc_publisher)
|
xmp_publisher = ', '.join(xmp_info.dc_publisher)
|
||||||
|
|
||||||
@ -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 use_pdf_meta:
|
if not use_generic_pdf_cover:
|
||||||
PVersion='v'+PyPdfVersion
|
ret['Wand'] = ImageVersion.VERSION
|
||||||
else:
|
else:
|
||||||
PVersion=u'not installed'
|
ret['Wand'] = u'not installed'
|
||||||
if lxmlversion:
|
if use_pdf_meta:
|
||||||
XVersion = 'v'+'.'.join(map(str, lxmlversion))
|
ret['PyPdf'] = PyPdfVersion
|
||||||
else:
|
else:
|
||||||
XVersion = u'not installed'
|
ret['PyPdf'] = u'not installed'
|
||||||
if comic.use_comic_meta:
|
if lxmlversion:
|
||||||
ComicVersion = comic.comic_version or u'installed'
|
ret['lxml'] = '.'.join(map(str, lxmlversion))
|
||||||
else:
|
else:
|
||||||
ComicVersion = u'not installed'
|
ret['lxml'] = u'not installed'
|
||||||
return {'Image Magick': IVersion,
|
if comic.use_comic_meta:
|
||||||
'PyPdf': PVersion,
|
ret['Comic_API'] = comic.comic_version or u'installed'
|
||||||
'lxml':XVersion,
|
else:
|
||||||
'Wand': WVersion,
|
ret['Comic_API'] = u'not installed'
|
||||||
# 'Pillow': PILVersion,
|
return ret
|
||||||
'Comic_API': ComicVersion}
|
|
||||||
|
|
||||||
|
|
||||||
def upload(uploadfile, rarExcecutable):
|
def upload(uploadfile, rarExcecutable):
|
||||||
|
Loading…
Reference in New Issue
Block a user