aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Task.py
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-06-03 22:50:02 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-06-03 22:50:02 +0000
commitb5513ae969d3d8e5a0870d21cf6c8499987b1135 (patch)
tree83e7f96669acc71029d08e97a5fb247ac3591cc0 /lib/python/Components/Task.py
parent8b5176ab8d8a334dfee75cfbda878240e2501823 (diff)
downloadenigma2-b5513ae969d3d8e5a0870d21cf6c8499987b1135.tar.gz
enigma2-b5513ae969d3d8e5a0870d21cf6c8499987b1135.zip
add cleanup call, implement DiskspacePrecondition, add WorkspaceExistsPrecondition
Diffstat (limited to 'lib/python/Components/Task.py')
-rw-r--r--lib/python/Components/Task.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py
index aebca732..075324b0 100644
--- a/lib/python/Components/Task.py
+++ b/lib/python/Components/Task.py
@@ -171,6 +171,7 @@ class Task(object) :
if not postcondition.check(self):
not_met.append(postcondition)
+ self.cleanup(not_met)
self.callback(not_met)
def afterRun(self):
@@ -248,14 +249,22 @@ class JobManager:
# if filesystem is not None:
# self.args += ["-t", filesystem]
# self.args.append(device + "part%d" % partition)
-#
-#class DiskspacePrecondition:
-# def __init__(self, diskspace_required):
-# self.diskspace_required = diskspace_required
-#
-# def check(self, task):
-# return getFreeDiskspace(task.workspace) >= self.diskspace_required
-#
+
+class WorkspaceExistsPrecondition:
+ def check(self, task):
+ return os.access(task.job.workspace, os.W_OK)
+
+class DiskspacePrecondition:
+ def __init__(self, diskspace_required):
+ self.diskspace_required = diskspace_required
+
+ def check(self, task):
+ import os
+ try:
+ s = os.statvfs(task.job.workspace)
+ return s.f_bsize * s.f_bavail >= self.diskspace_required
+ except OSError:
+ return False
class ToolExistsPrecondition:
def check(self, task):