aboutsummaryrefslogtreecommitdiff
path: root/ipsutils/task.py
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunk@stsci.edu>2013-04-22 11:17:44 -0400
committerJoseph Hunkeler <jhunk@stsci.edu>2013-04-22 11:19:34 -0400
commitf2288e48380a5557a49151fc95ee121baff65b56 (patch)
tree0592592bcb1f90ccc713c1c8ecf8d25ed93f1d15 /ipsutils/task.py
parent2027d81c8662e616f5255a83242dc62cae1cc50a (diff)
downloadipsutils-f2288e48380a5557a49151fc95ee121baff65b56.tar.gz
Rename ips to ipsutils
Diffstat (limited to 'ipsutils/task.py')
-rw-r--r--ipsutils/task.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/ipsutils/task.py b/ipsutils/task.py
new file mode 100644
index 0000000..1d8faeb
--- /dev/null
+++ b/ipsutils/task.py
@@ -0,0 +1,44 @@
+# This file is part of ipsutils.
+
+# ipsutils is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ipsutils is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ipsutils. If not, see <http://www.gnu.org/licenses/>.
+
+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
+ """
+ for stack_entry in self.stack:
+ stack_entry.run()
+
+class NamedTask(object):
+ def __init__(self, name, func, *args):
+ self.name = name
+ self.task = func
+ self.task_args = args
+
+ def run(self):
+ print("Running task: {0:s}".format(self.name))
+ status = self.task(self.task_args)
+ return status
+
+class InternalTask(NamedTask):
+ pass