aboutsummaryrefslogtreecommitdiff
path: root/ips/task.py
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2013-04-21 23:25:55 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2013-04-21 23:25:55 -0400
commit1f2b4af32761563219eb963bf48da9ebb3a6f6e3 (patch)
tree9a5a656763d90176bea02da0af44a6e18b365dae /ips/task.py
parent60ad0c3fd1c55be857ea902ff431db8d958efc64 (diff)
downloadipsutils-1f2b4af32761563219eb963bf48da9ebb3a6f6e3.tar.gz
* Created IPS package
* Major overhaul in progress
Diffstat (limited to 'ips/task.py')
-rw-r--r--ips/task.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/ips/task.py b/ips/task.py
new file mode 100644
index 0000000..6c84d51
--- /dev/null
+++ b/ips/task.py
@@ -0,0 +1,45 @@
+# class TaskController(list):
+# def __init__(self):
+# super(TaskController, self).__init__()
+# self._store = []
+#
+# def task(self, task):
+# super(TaskController, self).append(task)
+#
+# def do_tasks(self):
+# for task in super(TaskController, self).__iter__():
+# retval = task.run()
+# if not retval:
+# exit(retval)
+
+class TaskController(object):
+ def __init__(self):
+ self.stack = []
+
+ def task(self, t):
+ """
+ t: Task object
+ """
+ self.stack.append(t)
+
+ def do_tasks(self):
+ """ FILO execution of tasks
+ """
+ #self.stack.reverse()
+ for i in self.stack:
+ i.run()
+
+class NamedTask(object):
+ def __init__(self, name, func, *args):
+ self.name = name
+ self.task = func
+ self.task_args = args
+ print("New task: {0:s} {1:s}".format(self.name, self.task))
+
+ def run(self):
+ print("Running task: {0:s}".format(self.name))
+ status = self.task(self.task_args)
+ return status
+
+class InternalTask(NamedTask):
+ pass \ No newline at end of file