summaryrefslogtreecommitdiff
path: root/megapixels/app/server/tasks/__init__.py
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-01-14 22:25:25 +0100
committeradamhrv <adam@ahprojects.com>2019-01-14 22:25:25 +0100
commitdf9d364e3664f45c65cac5990d3d742b990217fa (patch)
tree8842d844a5ea8e6c87599b8683009cba23262713 /megapixels/app/server/tasks/__init__.py
parent2fedd95fcee3f048c5f24333ffdb9bb4e13eafe2 (diff)
parent3b2f0dc6d969fa323fe8775b4269e17c60192431 (diff)
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'megapixels/app/server/tasks/__init__.py')
-rw-r--r--megapixels/app/server/tasks/__init__.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/megapixels/app/server/tasks/__init__.py b/megapixels/app/server/tasks/__init__.py
new file mode 100644
index 00000000..c0db0be5
--- /dev/null
+++ b/megapixels/app/server/tasks/__init__.py
@@ -0,0 +1,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,
+ }
+}