From: Felix Domke Date: Tue, 10 Jun 2008 12:04:59 +0000 (+0000) Subject: clamp progress to 0..end, add possibility to receive whole lines only in processOutpu... X-Git-Tag: 2.6.0~1144 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/c98c3f3d1909a5a8ef6ac051da2998e68151378a clamp progress to 0..end, add possibility to receive whole lines only in processOutputLine --- 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()