Partial fix to #617. Local status messages now work.
This commit is contained in:
parent
0bb148e6e3
commit
b4122e9858
|
@ -567,3 +567,24 @@ def get_current_version_info():
|
||||||
if is_sha1(content[0]) and len(content[1]) > 0:
|
if is_sha1(content[0]) and len(content[1]) > 0:
|
||||||
return {'hash': content[0], 'datetime': content[1]}
|
return {'hash': content[0], 'datetime': content[1]}
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def render_task_status(tasklist):
|
||||||
|
#helper function to apply localize status information in tasklist entries
|
||||||
|
renderedtasklist=list()
|
||||||
|
|
||||||
|
for task in tasklist:
|
||||||
|
if isinstance( task['status'], int ):
|
||||||
|
if task['status'] == worker.STAT_WAITING:
|
||||||
|
task['status'] = _('Waiting')
|
||||||
|
elif task['status'] == worker.STAT_FAIL:
|
||||||
|
task['status'] = _('Failed')
|
||||||
|
elif task['status'] == worker.STAT_STARTED:
|
||||||
|
task['status'] = _('Started')
|
||||||
|
elif task['status'] == worker.STAT_FINISH_SUCCESS:
|
||||||
|
task['status'] = _('Finished')
|
||||||
|
else:
|
||||||
|
task['status'] = _('Unknown Status')
|
||||||
|
renderedtasklist.append(task)
|
||||||
|
|
||||||
|
return renderedtasklist
|
||||||
|
|
13
cps/web.py
13
cps/web.py
|
@ -85,6 +85,7 @@ import hashlib
|
||||||
from redirect import redirect_back
|
from redirect import redirect_back
|
||||||
import time
|
import time
|
||||||
import server
|
import server
|
||||||
|
import copy
|
||||||
try:
|
try:
|
||||||
import cPickle
|
import cPickle
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -873,6 +874,7 @@ def get_metadata_calibre_companion(uuid):
|
||||||
@login_required
|
@login_required
|
||||||
def get_email_status_json():
|
def get_email_status_json():
|
||||||
answer=list()
|
answer=list()
|
||||||
|
UIanswer = list()
|
||||||
tasks=helper.global_WorkerThread.get_taskstatus()
|
tasks=helper.global_WorkerThread.get_taskstatus()
|
||||||
if not current_user.role_admin():
|
if not current_user.role_admin():
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
|
@ -893,7 +895,11 @@ def get_email_status_json():
|
||||||
if 'starttime' not in task:
|
if 'starttime' not in task:
|
||||||
task['starttime'] = ""
|
task['starttime'] = ""
|
||||||
answer = tasks
|
answer = tasks
|
||||||
js=json.dumps(answer)
|
|
||||||
|
UIanswer = copy.deepcopy(answer)
|
||||||
|
UIanswer = helper.render_task_status(UIanswer)
|
||||||
|
|
||||||
|
js=json.dumps(UIanswer)
|
||||||
response = make_response(js)
|
response = make_response(js)
|
||||||
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
response.headers["Content-Type"] = "application/json; charset=utf-8"
|
||||||
return response
|
return response
|
||||||
|
@ -1626,6 +1632,7 @@ def bookmark(book_id, book_format):
|
||||||
def get_tasks_status():
|
def get_tasks_status():
|
||||||
# if current user admin, show all email, otherwise only own emails
|
# if current user admin, show all email, otherwise only own emails
|
||||||
answer=list()
|
answer=list()
|
||||||
|
UIanswer=list()
|
||||||
tasks=helper.global_WorkerThread.get_taskstatus()
|
tasks=helper.global_WorkerThread.get_taskstatus()
|
||||||
if not current_user.role_admin():
|
if not current_user.role_admin():
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
|
@ -1647,8 +1654,10 @@ def get_tasks_status():
|
||||||
task['starttime'] = ""
|
task['starttime'] = ""
|
||||||
answer = tasks
|
answer = tasks
|
||||||
|
|
||||||
|
UIanswer = copy.deepcopy(answer)
|
||||||
|
UIanswer = helper.render_task_status(UIanswer)
|
||||||
# foreach row format row
|
# foreach row format row
|
||||||
return render_title_template('tasks.html', entries=answer, title=_(u"Tasks"))
|
return render_title_template('tasks.html', entries=UIanswer, title=_(u"Tasks"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/admin")
|
@app.route("/admin")
|
||||||
|
|
|
@ -212,7 +212,7 @@ class WorkerThread(threading.Thread):
|
||||||
def convert_any_format(self):
|
def convert_any_format(self):
|
||||||
# convert book, and upload in case of google drive
|
# convert book, and upload in case of google drive
|
||||||
self.queue[self.current]['status'] = STAT_STARTED
|
self.queue[self.current]['status'] = STAT_STARTED
|
||||||
self.UIqueue[self.current]['status'] = _('Started')
|
self.UIqueue[self.current]['status'] = STAT_STARTED
|
||||||
self.queue[self.current]['starttime'] = datetime.now()
|
self.queue[self.current]['starttime'] = datetime.now()
|
||||||
self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime']
|
self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime']
|
||||||
curr_task = self.queue[self.current]['typ']
|
curr_task = self.queue[self.current]['typ']
|
||||||
|
@ -352,7 +352,7 @@ class WorkerThread(threading.Thread):
|
||||||
self.queue.append({'file_path':file_path, 'bookid':bookid, 'starttime': 0, 'kindle': kindle_mail,
|
self.queue.append({'file_path':file_path, 'bookid':bookid, 'starttime': 0, 'kindle': kindle_mail,
|
||||||
'status': STAT_WAITING, 'typ': task, 'settings':settings})
|
'status': STAT_WAITING, 'typ': task, 'settings':settings})
|
||||||
self.UIqueue.append({'user': user_name, 'formStarttime': '', 'progress': " 0 %", 'type': typ,
|
self.UIqueue.append({'user': user_name, 'formStarttime': '', 'progress': " 0 %", 'type': typ,
|
||||||
'runtime': '0 s', 'status': _('Waiting'),'id': self.id } )
|
'runtime': '0 s', 'status': STAT_WAITING,'id': self.id } )
|
||||||
|
|
||||||
self.last=len(self.queue)
|
self.last=len(self.queue)
|
||||||
addLock.release()
|
addLock.release()
|
||||||
|
@ -371,7 +371,7 @@ class WorkerThread(threading.Thread):
|
||||||
'settings':settings, 'recipent':recipient, 'starttime': 0,
|
'settings':settings, 'recipent':recipient, 'starttime': 0,
|
||||||
'status': STAT_WAITING, 'typ': TASK_EMAIL, 'text':text})
|
'status': STAT_WAITING, 'typ': TASK_EMAIL, 'text':text})
|
||||||
self.UIqueue.append({'user': user_name, 'formStarttime': '', 'progress': " 0 %", 'type': typ,
|
self.UIqueue.append({'user': user_name, 'formStarttime': '', 'progress': " 0 %", 'type': typ,
|
||||||
'runtime': '0 s', 'status': _('Waiting'),'id': self.id })
|
'runtime': '0 s', 'status': STAT_WAITING,'id': self.id })
|
||||||
self.last=len(self.queue)
|
self.last=len(self.queue)
|
||||||
addLock.release()
|
addLock.release()
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ class WorkerThread(threading.Thread):
|
||||||
self.queue[self.current]['starttime'] = datetime.now()
|
self.queue[self.current]['starttime'] = datetime.now()
|
||||||
self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime']
|
self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime']
|
||||||
self.queue[self.current]['status'] = STAT_STARTED
|
self.queue[self.current]['status'] = STAT_STARTED
|
||||||
self.UIqueue[self.current]['status'] = _('Started')
|
self.UIqueue[self.current]['status'] = STAT_STARTED
|
||||||
obj=self.queue[self.current]
|
obj=self.queue[self.current]
|
||||||
# create MIME message
|
# create MIME message
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
@ -473,7 +473,7 @@ class WorkerThread(threading.Thread):
|
||||||
def _handleError(self, error_message):
|
def _handleError(self, error_message):
|
||||||
web.app.logger.error(error_message)
|
web.app.logger.error(error_message)
|
||||||
self.queue[self.current]['status'] = STAT_FAIL
|
self.queue[self.current]['status'] = STAT_FAIL
|
||||||
self.UIqueue[self.current]['status'] = _('Failed')
|
self.UIqueue[self.current]['status'] = STAT_FAIL
|
||||||
self.UIqueue[self.current]['progress'] = "100 %"
|
self.UIqueue[self.current]['progress'] = "100 %"
|
||||||
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
|
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
|
||||||
datetime.now() - self.queue[self.current]['starttime'])
|
datetime.now() - self.queue[self.current]['starttime'])
|
||||||
|
@ -481,7 +481,7 @@ class WorkerThread(threading.Thread):
|
||||||
|
|
||||||
def _handleSuccess(self):
|
def _handleSuccess(self):
|
||||||
self.queue[self.current]['status'] = STAT_FINISH_SUCCESS
|
self.queue[self.current]['status'] = STAT_FINISH_SUCCESS
|
||||||
self.UIqueue[self.current]['status'] = _('Finished')
|
self.UIqueue[self.current]['status'] = STAT_FINISH_SUCCESS
|
||||||
self.UIqueue[self.current]['progress'] = "100 %"
|
self.UIqueue[self.current]['progress'] = "100 %"
|
||||||
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
|
self.UIqueue[self.current]['runtime'] = self._formatRuntime(
|
||||||
datetime.now() - self.queue[self.current]['starttime'])
|
datetime.now() - self.queue[self.current]['starttime'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user