changeset 1154:a1625e68b726

server (tasks): task can now use a "prepare" method to prepare data before running (e.g. WATCH_DIRS)
author Goffi <goffi@goffi.org>
date Fri, 22 Feb 2019 18:42:47 +0100
parents 94f9d81a475e
children 813d54af8c0c
files libervia/server/tasks.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/tasks.py	Fri Feb 22 16:57:37 2019 +0100
+++ b/libervia/server/tasks.py	Fri Feb 22 18:42:47 2019 +0100
@@ -119,6 +119,14 @@
                 u'data': task_data,
             }
             execfile(filepath, task_data)
+            # we launch prepare, which is a method used to prepare
+            # data at runtime (e.g. set WATCH_DIRS using config)
+            try:
+                prepare = task_data['prepare']
+            except KeyError:
+                pass
+            else:
+                prepare(self)
             self.validateData(task_data)
 
     @defer.inlineCallbacks