diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2008-06-10 12:04:59 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2008-06-10 12:04:59 +0000 |
| commit | c98c3f3d1909a5a8ef6ac051da2998e68151378a (patch) | |
| tree | 0ca4fe6b3f44a8f4938d929066c5a895892ef892 | |
| parent | 8da4bc6c15dfe6d702277482e83f4f0bf346ab0b (diff) | |
| download | enigma2-c98c3f3d1909a5a8ef6ac051da2998e68151378a.tar.gz enigma2-c98c3f3d1909a5a8ef6ac051da2998e68151378a.zip | |
clamp progress to 0..end, add possibility to receive whole lines only in processOutputLine
| -rw-r--r-- | lib/python/Components/Task.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 075324b0..c59086e1 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -97,6 +97,7 @@ class Task(object) : self.cwd = "/tmp" self.args = [ ] self.task_progress_changed = None + self.output_line = "" job.addTask(self) def setCommandline(self, cmd, args): @@ -151,6 +152,15 @@ class Task(object) : pass def processOutput(self, data): + self.output_line += data + while True: + i = self.output_line.find('\n') + if i == -1: + break + self.processOutputLine(self.output_line[:i+1]) + self.output_line = self.output_line[i+1:] + + def processOutputLine(self, line): pass def processFinished(self, returncode): @@ -184,6 +194,10 @@ class Task(object) : return self.__progress def setProgress(self, progress): + if progress > self.end: + progress = self.end + if progress < 0: + progress = 0 print "progress now", progress self.__progress = progress self.task_progress_changed() |
