1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-19 01:27:40 +00:00

Fix duplicate user and email (now case insensitive #948)

Fix sorting in comics (#950)
Fix log error on Calibre converter error (#953)
Fix long running tasks (#954)
This commit is contained in:
Ozzieisaacs
2019-06-30 11:20:36 +02:00
parent 66283c542f
commit f79d549910
8 changed files with 184 additions and 559 deletions

View File

@@ -34,7 +34,8 @@ from flask import send_from_directory, make_response, redirect, abort
from flask_babel import gettext as _
from flask_login import current_user
from babel.dates import format_datetime
from datetime import datetime
from babel.units import format_unit
from datetime import datetime, timedelta
import shutil
import requests
try:
@@ -566,8 +567,33 @@ def json_serial(obj):
if isinstance(obj, (datetime)):
return obj.isoformat()
if isinstance(obj, (timedelta)):
return {
'__type__': 'timedelta',
'days': obj.days,
'seconds': obj.seconds,
'microseconds': obj.microseconds,
}
raise TypeError ("Type %s not serializable" % type(obj))
# helper function for displaying the runtime of tasks
def format_runtime(runtime):
retVal = ""
if runtime.days:
retVal = format_unit(runtime.days, 'duration-day', length="long", locale=web.get_locale()) + ', '
mins, seconds = divmod(runtime.seconds, 60)
hours, minutes = divmod(mins, 60)
# ToDo: locale.number_symbols._data['timeSeparator'] -> localize time separator ?
if hours:
retVal += '{:d}:{:02d}:{:02d}s'.format(hours, minutes, seconds)
elif minutes:
retVal += '{:2d}:{:02d}s'.format(minutes, seconds)
else:
retVal += '{:2d}s'.format(seconds)
return retVal
# helper function to apply localize status information in tasklist entries
def render_task_status(tasklist):
renderedtasklist=list()
@@ -579,6 +605,8 @@ def render_task_status(tasklist):
if 'starttime' not in task:
task['starttime'] = ""
task['runtime'] = format_runtime(task['formRuntime'])
# localize the task status
if isinstance( task['stat'], int ):
if task['stat'] == worker.STAT_WAITING: