Mercurial > libervia-web
comparison libervia/server/tasks.py @ 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 | 02afab1b15c5 |
children | 813d54af8c0c |
comparison
equal
deleted
inserted
replaced
1153:94f9d81a475e | 1154:a1625e68b726 |
---|---|
117 self.tasks[task_name] = { | 117 self.tasks[task_name] = { |
118 u'path': filepath, | 118 u'path': filepath, |
119 u'data': task_data, | 119 u'data': task_data, |
120 } | 120 } |
121 execfile(filepath, task_data) | 121 execfile(filepath, task_data) |
122 # we launch prepare, which is a method used to prepare | |
123 # data at runtime (e.g. set WATCH_DIRS using config) | |
124 try: | |
125 prepare = task_data['prepare'] | |
126 except KeyError: | |
127 pass | |
128 else: | |
129 prepare(self) | |
122 self.validateData(task_data) | 130 self.validateData(task_data) |
123 | 131 |
124 @defer.inlineCallbacks | 132 @defer.inlineCallbacks |
125 def runTasks(self): | 133 def runTasks(self): |
126 """Run all the tasks found""" | 134 """Run all the tasks found""" |