1 from Screen import Screen
2 from InfoBarGenerics import InfoBarNotifications
4 class JobView(InfoBarNotifications, Screen):
5 def __init__(self, session, job, cancelable = True, close_on_finish = False):
6 from Components.Sources.StaticText import StaticText
7 from Components.Sources.Progress import Progress
8 from Components.Sources.Boolean import Boolean
9 from Components.ActionMap import ActionMap
10 Screen.__init__(self, session)
11 InfoBarNotifications.__init__(self)
13 self.close_on_finish = close_on_finish
14 self.cancelable = cancelable
16 self["job_name"] = StaticText(job.name)
17 self["job_progress"] = Progress()
18 self["job_status"] = StaticText()
19 self["job_task"] = StaticText()
20 self["finished"] = Boolean()
22 self.onShow.append(self.windowShow)
23 self.onHide.append(self.windowHide)
25 self["actions"] = ActionMap(["OkCancelActions"],
32 self.job.state_changed.append(self.state_changed)
36 if len(self.job.state_changed) > 0:
37 self.job.state_changed.remove(self.state_changed)
39 def state_changed(self):
41 self["job_progress"].range = j.end
42 self["job_progress"].value = j.progress
43 print "JobView::state_changed:", j.end, j.progress
44 self["job_status"].text = {j.NOT_STARTED: _("Waiting"), j.IN_PROGRESS: _("In Progress"), j.FINISHED: _("Finished"), j.FAILED: _("Failed")}[j.status]
45 if j.status == j.IN_PROGRESS:
46 self["job_task"].text = j.tasks[j.current_task].name
48 self["job_task"].text = ""
49 if j.status in [j.FINISHED, j.FAILED]:
50 if self.close_on_finish:
53 self["finished"].boolean = True
56 if self.job.status in [self.job.FINISHED, self.job.FAILED]:
60 if self.job.status in [self.job.FINISHED, self.job.FAILED]: