Added command line option or overwriting limiter backend

Added logger functions to remove newlines in messages
CalibreTask has now a default name
This commit is contained in:
Ozzie Isaacs 2024-02-25 16:02:01 +01:00
parent 3c4ed0de1a
commit c3fc125501
5 changed files with 22 additions and 3 deletions

View File

@ -198,7 +198,7 @@ def create_app():
# Configure rate limiter
# https://limits.readthedocs.io/en/stable/storage.html
app.config.update(RATELIMIT_ENABLED=config.config_ratelimiter)
if config.config_limiter_uri != "":
if config.config_limiter_uri != "" and not cli_param.memory_backend:
app.config.update(RATELIMIT_STORAGE_URI=config.config_limiter_uri)
if config.config_limiter_options != "":
app.config.update(RATELIMIT_STORAGE_OPTIONS=config.config_limiter_options)

View File

@ -52,6 +52,7 @@ class CliParameter(object):
parser.add_argument('-v', '--version', action='version', help='Shows version number and exits Calibre-Web',
version=version_info())
parser.add_argument('-i', metavar='ip-address', help='Server IP-Address to listen')
parser.add_argument('-m', action='store_true', help='Use Memory-backend as limiter backend, use this parameter in case of miss configured backend')
parser.add_argument('-s', metavar='user:pass',
help='Sets specific username to new password and exits Calibre-Web')
parser.add_argument('-f', action='store_true', help='Flag is depreciated and will be removed in next version')
@ -98,6 +99,8 @@ class CliParameter(object):
if args.k == "":
self.keyfilepath = ""
# overwrite limiter backend
self.memory_backend = args.m or None
# dry run updater
self.dry_run = args.d or None
# enable reconnect endpoint for docker database reconnect

View File

@ -61,6 +61,19 @@ class _Logger(logging.Logger):
else:
self.debug(message, *args, **kwargs)
def warning(self, message, *args, **kwargs):
message = message.replace("\r", "").replace("\n", "")
list_args = list(args)
for index, arg in enumerate(list_args):
list_args[index] = arg.replace("\r", "").replace("\n", "")
args = tuple(list_args)
super().warning(message, *args, **kwargs)
def debug(self, message, *args, **kwargs):
message = message.replace("\r", "").replace("\n", "")
super().debug(message, *args, **kwargs)
def get(name=None):
return logging.getLogger(name)

View File

@ -266,3 +266,6 @@ class CalibreTask:
def _handleSuccess(self):
self.stat = STAT_FINISH_SUCCESS
self.progress = 1
def __str__(self):
return self.name

View File

@ -316,9 +316,9 @@ class TaskConvert(CalibreTask):
def __str__(self):
if self.ereader_mail:
return "Convert {} {}".format(self.book_id, self.ereader_mail)
return "Convert Book {} and mail it to {}".format(self.book_id, self.ereader_mail)
else:
return "Convert {}".format(self.book_id)
return "Convert Book {}".format(self.book_id)
@property
def is_cancellable(self):