1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import simplejson as json
from app.settings import app_cfg as cfg
from celery import Celery
celery = Celery(__name__, backend=cfg.CELERY_RESULT_BACKEND, broker=cfg.CELERY_BROKER_URL)
from app.server.tasks.sleep import sleep_task
from app.server.tasks.blur import blur_task
from app.server.tasks.demo import demo_task
def list_active_tasks():
dropdown = {}
for k,v in task_lookup.items():
if 'active' not in v or v['active'] is not False:
is_default = 'default' in v and v['default'] is True
task = {
'name': k,
'title': v['title'],
'selected': is_default,
}
dropdown[k] = task
return dropdown
###################################################################
# Add all valid tasks to this lookup.
# Set 'active': False to disable a task
# Set 'default': True to define the default task
task_lookup = {
'sleep': {
'title': 'Sleep Test',
'task': sleep_task,
'active': True,
'default': True,
},
'blur': {
'title': 'Blur',
'task': blur_task,
'active': True,
},
'demo': {
'title': 'Facial processing pipeline',
'task': demo_task,
'active': True,
'default': True,
}
}
|