Mercurial > lcfOS
comparison python/ppci/tasks.py @ 332:87feb8a23b4d
Added task list command
author | Windel Bouwman |
---|---|
date | Fri, 07 Feb 2014 12:51:55 +0100 |
parents | 8f6f3ace4e78 |
children | 6f4753202b9a |
comparison
equal
deleted
inserted
replaced
331:a78b41ff6ad2 | 332:87feb8a23b4d |
---|---|
25 | 25 |
26 def addDependency(self, task): | 26 def addDependency(self, task): |
27 self.dependencies.append(task) | 27 self.dependencies.append(task) |
28 return task | 28 return task |
29 | 29 |
30 def __repr__(self): | |
31 return 'Task "{}"'.format(self.name) | |
32 | |
30 | 33 |
31 class TaskRunner: | 34 class TaskRunner: |
35 """ Basic task runner that can run some tasks in sequence """ | |
32 def __init__(self): | 36 def __init__(self): |
33 self.task_list = [] | 37 self.task_list = [] |
34 | 38 |
35 def add_task(self, task): | 39 def add_task(self, task): |
36 self.task_list.append(task) | 40 self.task_list.append(task) |
37 | 41 |
38 def run_tasks(self): | 42 def run_tasks(self): |
39 try: | 43 try: |
42 t.fire() | 46 t.fire() |
43 except TaskError as e: | 47 except TaskError as e: |
44 print('Error: {}'.format(e)) | 48 print('Error: {}'.format(e)) |
45 return 1 | 49 return 1 |
46 return 0 | 50 return 0 |
51 | |
52 def display(self): | |
53 """ Display task how they would be run """ | |
54 for task in self.task_list: | |
55 print(task) |