1 from Screen import Screen
4 def __init__(self, session, job, cancelable = True, close_on_finish = False):
5 from Components.Sources.StaticText import StaticText
6 from Components.Sources.Progress import Progress
7 from Components.ActionMap import ActionMap
8 Screen.__init__(self, session)
10 self.close_on_finish = close_on_finish
12 self["job_name"] = StaticText(job.name)
13 self["job_progress"] = Progress()
14 self["job_status"] = StaticText()
15 self["job_task"] = StaticText()
17 self.onShow.append(self.windowShow)
18 self.onHide.append(self.windowHide)
20 self["actions"] = ActionMap(["OkCancelActions"],
27 self.job.state_changed.append(self.state_changed)
31 self.job.state_changed.remove(self.state_changed)
33 def state_changed(self):
35 self["job_progress"].range = len(j.tasks)
36 self["job_progress"].value = j.current_task
37 self["job_status"].text = {j.NOT_STARTED: _("Waiting"), j.IN_PROGRESS: _("In Progress"), j.FINISHED: _("Finished"), j.FAILED: _("Failed")}[j.status]
38 if j.status == j.IN_PROGRESS:
39 self["job_task"].text = j.tasks[j.current_task].name
41 self["job_task"].text = ""
42 if j.status in [j.FINISHED, j.FAILED] and self.close_on_finish:
46 if self.job.status in [self.job.FINISHED, self.job.FAILED]:
50 if self.job.status in [self.job.FINISHED, self.job.FAILED]: