2019-02-08 19:11:44 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
# Copyright (C) 2018-2019 OzzieIsaacs, cervinko, jkrehm, bodybybuddha, ok11,
|
|
|
|
# andy29485, idalin, Kyosfonica, wuqi, Kennyl, lemmsh,
|
|
|
|
# falgh1, grunjol, csitko, ytils, xybydy, trasba, vrabe,
|
|
|
|
# ruben-herold, marblepebble, JackED42, SiphonSquirrel,
|
|
|
|
# apetresc, nanu-c, mutschler
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import sys
|
2019-12-15 12:33:38 +00:00
|
|
|
import platform
|
2019-07-14 17:38:07 +00:00
|
|
|
import sqlite3
|
|
|
|
from collections import OrderedDict
|
2019-02-08 19:11:44 +00:00
|
|
|
|
2022-01-31 18:19:25 +00:00
|
|
|
import babel
|
|
|
|
import pytz
|
|
|
|
import requests
|
|
|
|
import sqlalchemy
|
|
|
|
import werkzeug
|
|
|
|
import flask
|
|
|
|
import flask_login
|
|
|
|
import flask_principal
|
|
|
|
import jinja2
|
2019-06-06 15:10:22 +00:00
|
|
|
from flask_babel import gettext as _
|
2021-10-04 15:50:32 +00:00
|
|
|
try:
|
|
|
|
from flask_wtf import __version__ as flaskwtf_version
|
|
|
|
except ImportError:
|
|
|
|
flaskwtf_version = _(u'not installed')
|
2019-06-06 15:10:22 +00:00
|
|
|
|
2021-11-06 16:17:00 +00:00
|
|
|
from . import db, calibre_db, converter, uploader, server, isoLanguages, constants, gdriveutils, dep_check
|
2020-12-12 10:23:17 +00:00
|
|
|
from .render_template import render_title_template
|
2021-11-06 16:17:00 +00:00
|
|
|
|
2019-07-21 15:45:21 +00:00
|
|
|
try:
|
|
|
|
from flask_login import __version__ as flask_loginVersion
|
|
|
|
except ImportError:
|
|
|
|
from flask_login.__about__ import __version__ as flask_loginVersion
|
2019-08-06 16:38:17 +00:00
|
|
|
try:
|
2021-03-15 12:48:05 +00:00
|
|
|
# pylint: disable=unused-import
|
2019-08-06 16:38:17 +00:00
|
|
|
import unidecode
|
2019-10-20 13:48:06 +00:00
|
|
|
# _() necessary to make babel aware of string for translation
|
2019-08-06 16:38:17 +00:00
|
|
|
unidecode_version = _(u'installed')
|
|
|
|
except ImportError:
|
|
|
|
unidecode_version = _(u'not installed')
|
2019-02-08 19:11:44 +00:00
|
|
|
|
2020-04-15 17:57:33 +00:00
|
|
|
try:
|
|
|
|
from flask_dance import __version__ as flask_danceVersion
|
|
|
|
except ImportError:
|
|
|
|
flask_danceVersion = None
|
|
|
|
|
2021-02-06 08:42:27 +00:00
|
|
|
try:
|
|
|
|
from greenlet import __version__ as greenlet_Version
|
|
|
|
except ImportError:
|
|
|
|
greenlet_Version = None
|
|
|
|
|
2019-08-06 17:53:24 +00:00
|
|
|
from . import services
|
|
|
|
|
2019-07-14 17:38:07 +00:00
|
|
|
about = flask.Blueprint('about', __name__)
|
|
|
|
|
2021-11-06 16:17:00 +00:00
|
|
|
ret = dict()
|
|
|
|
req = dep_check.load_dependencys(False)
|
|
|
|
opt = dep_check.load_dependencys(True)
|
|
|
|
for i in (req + opt):
|
|
|
|
ret[i[1]] = i[0]
|
|
|
|
|
2021-12-28 19:17:51 +00:00
|
|
|
if constants.NIGHTLY_VERSION[0] == "$Format:%H$":
|
|
|
|
calibre_web_version = constants.STABLE_VERSION['version']
|
|
|
|
else:
|
|
|
|
calibre_web_version = (constants.STABLE_VERSION['version'] + ' - '
|
2022-01-31 18:19:25 +00:00
|
|
|
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
|
|
|
|
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
|
2022-02-12 10:20:09 +00:00
|
|
|
|
2021-12-28 19:17:51 +00:00
|
|
|
if getattr(sys, 'frozen', False):
|
|
|
|
calibre_web_version += " - Exe-Version"
|
|
|
|
elif constants.HOME_CONFIG:
|
|
|
|
calibre_web_version += " - pyPi"
|
|
|
|
|
2021-11-06 16:17:00 +00:00
|
|
|
if not ret:
|
|
|
|
_VERSIONS = OrderedDict(
|
2022-01-31 18:19:25 +00:00
|
|
|
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
2021-11-06 16:17:00 +00:00
|
|
|
Python=sys.version,
|
2021-12-28 19:17:51 +00:00
|
|
|
Calibre_Web=calibre_web_version,
|
2021-11-06 16:17:00 +00:00
|
|
|
WebServer=server.VERSION,
|
|
|
|
Flask=flask.__version__,
|
|
|
|
Flask_Login=flask_loginVersion,
|
|
|
|
Flask_Principal=flask_principal.__version__,
|
|
|
|
Flask_WTF=flaskwtf_version,
|
|
|
|
Werkzeug=werkzeug.__version__,
|
|
|
|
Babel=babel.__version__,
|
|
|
|
Jinja2=jinja2.__version__,
|
|
|
|
Requests=requests.__version__,
|
|
|
|
SqlAlchemy=sqlalchemy.__version__,
|
|
|
|
pySqlite=sqlite3.version,
|
|
|
|
SQLite=sqlite3.sqlite_version,
|
|
|
|
iso639=isoLanguages.__version__,
|
|
|
|
pytz=pytz.__version__,
|
|
|
|
Unidecode=unidecode_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,
|
|
|
|
jsonschema=services.SyncToken.__version__ if bool(services.SyncToken) else None,
|
|
|
|
flask_dance=flask_danceVersion,
|
|
|
|
greenlet=greenlet_Version
|
|
|
|
)
|
|
|
|
_VERSIONS.update(gdriveutils.get_versions())
|
|
|
|
_VERSIONS.update(uploader.get_versions(True))
|
|
|
|
else:
|
|
|
|
_VERSIONS = OrderedDict(
|
2022-01-31 18:19:25 +00:00
|
|
|
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
|
|
|
Python=sys.version,
|
2021-12-28 19:17:51 +00:00
|
|
|
Calibre_Web=calibre_web_version,
|
2022-01-31 18:19:25 +00:00
|
|
|
Werkzeug=werkzeug.__version__,
|
2021-11-06 16:17:00 +00:00
|
|
|
Jinja2=jinja2.__version__,
|
2022-01-31 18:19:25 +00:00
|
|
|
pySqlite=sqlite3.version,
|
|
|
|
SQLite=sqlite3.sqlite_version,
|
2021-11-06 16:17:00 +00:00
|
|
|
)
|
|
|
|
_VERSIONS.update(ret)
|
|
|
|
_VERSIONS.update(uploader.get_versions(False))
|
2019-02-08 19:11:44 +00:00
|
|
|
|
2022-01-31 18:19:25 +00:00
|
|
|
|
2020-11-15 13:19:25 +00:00
|
|
|
def collect_stats():
|
|
|
|
_VERSIONS['ebook converter'] = _(converter.get_calibre_version())
|
|
|
|
_VERSIONS['unrar'] = _(converter.get_unrar_version())
|
|
|
|
_VERSIONS['kepubify'] = _(converter.get_kepubify_version())
|
|
|
|
return _VERSIONS
|
|
|
|
|
2022-01-31 18:19:25 +00:00
|
|
|
|
2019-02-08 19:11:44 +00:00
|
|
|
@about.route("/stats")
|
2019-07-14 17:38:07 +00:00
|
|
|
@flask_login.login_required
|
2019-02-08 19:11:44 +00:00
|
|
|
def stats():
|
2020-05-21 16:16:11 +00:00
|
|
|
counter = calibre_db.session.query(db.Books).count()
|
|
|
|
authors = calibre_db.session.query(db.Authors).count()
|
|
|
|
categorys = calibre_db.session.query(db.Tags).count()
|
|
|
|
series = calibre_db.session.query(db.Series).count()
|
2020-11-15 13:19:25 +00:00
|
|
|
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
|
2019-02-08 19:11:44 +00:00
|
|
|
categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat")
|