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 self.job.state_changed.remove(self.state_changed)
38 def state_changed(self):
40 self["job_progress"].range = j.end
41 self["job_progress"].value = j.progress
42 print "JobView::state_changed:", j.end, j.progress
43 self["job_status"].text = {j.NOT_STARTED: _("Waiting"), j.IN_PROGRESS: _("In Progress"), j.FINISHED: _("Finished"), j.FAILED: _("Failed")}[j.status]
44 if j.status == j.IN_PROGRESS:
45 self["job_task"].text = j.tasks[j.current_task].name
47 self["job_task"].text = ""
48 if j.status in [j.FINISHED, j.FAILED]:
49 if self.close_on_finish:
52 self["finished"].boolean = True
55 if self.job.status in [self.job.FINISHED, self.job.FAILED]:
59 if self.job.status in [self.job.FINISHED, self.job.FAILED]: