-class NFIDownload(Screen):
- LIST_SOURCE = 1
- LIST_DEST = 2
- skin = """
- <screen name="NFIDownload" position="90,95" size="560,420" title="Image download utility">
- <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
- <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
- <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
- <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
- <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;19" valign="center" halign="center" backgroundColor="#9f1313" transparent="1" />
- <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;19" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
- <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;19" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
- <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;19" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
-
- <widget source="label_top" render="Label" position="10,44" size="240,20" font="Regular;16" />
- <widget name="feedlist" position="10,66" size="250,222" scrollbarMode="showOnDemand" />
- <widget name="destlist" position="0,66" size="260,222" scrollbarMode="showOnDemand" />
-
- <widget source="label_bottom" render="Label" position="10,312" size="240,18" font="Regular;16"/>
- <widget source="path_bottom" render="Label" position="10,330" size="250,42" font="Regular;18" />
-
- <widget source="infolabel" render="Label" position="270,44" size="280,284" font="Regular;16" />
- <widget source="job_progressbar" render="Progress" position="10,374" size="540,26" borderWidth="1" backgroundColor="#254f7497" />
- <widget source="job_progresslabel" render="Label" position="130,378" zPosition="2" font="Regular;18" halign="center" transparent="1" size="300,22" foregroundColor="#000000" />
- <widget source="statusbar" render="Label" position="10,404" size="540,16" font="Regular;16" foregroundColor="#cccccc" />
- </screen>"""
-
- def __init__(self, session, destdir="/tmp/"):
- self.skin = NFIDownload.skin
- Screen.__init__(self, session)
-
- self["job_progressbar"] = Progress()
- self["job_progresslabel"] = StaticText()
-
- self["infolabel"] = StaticText()
- self["statusbar"] = StaticText()
- self["label_top"] = StaticText()
- self["label_bottom"] = StaticText()
- self["path_bottom"] = StaticText()
-
- self["key_green"] = StaticText()
- self["key_yellow"] = StaticText()
- self["key_blue"] = StaticText()
-
- self["key_red"] = StaticText()
-
- self["feedlist"] = Feedlist([0,(eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, "feed not available")])
- self["destlist"] = FileList(destdir, showDirectories = True, showFiles = False)
- self["destlist"].hide()
-
- self.download_container = eConsoleAppContainer()
- self.nfo = ""
- self.nfofile = ""
- self.feedhtml = ""
- self.focus = None
- self.download = None
- self.box = HardwareInfo().get_device_name()
- self.feed_base = "http://www.dreamboxupdate.com/opendreambox/1.5/%s/images/" % self.box
- self.nfi_filter = "" # "release" # only show NFIs containing this string, or all if ""
- self.wizard_mode = False
-
- self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "EPGSelectActions"],
- {
- "cancel": self.closeCB,
- "red": self.closeCB,
- "green": self.nfi_download,
- "yellow": self.switchList,
- "blue": self.askCreateUSBstick,
- "prevBouquet": self.switchList,
- "nextBouquet": self.switchList,
- "ok": self.ok,
- "left": self.left,
- "right": self.right,
- "up": self.up,
- "upRepeated": self.up,
- "downRepeated": self.down,
- "down": self.down
- }, -1)
-
- self.feed_download()
-
- def downloading(self, state=True):
- if state is True:
- self["key_red"].text = _("Cancel")
- self["key_green"].text = ""
- self["key_yellow"].text = ""
- self["key_blue"].text = ""
- else:
- self.download = None
- self["key_red"].text = _("Exit")
- if self["feedlist"].isValid():
- self["key_green"].text = (_("Download"))
- if self.focus is self.LIST_SOURCE:
- self["key_yellow"].text = (_("Change dir."))
- else:
- self["key_yellow"].text = (_("Select image"))
- self["key_blue"].text = (_("USB stick wizard"))
-
- def switchList(self,to_where=None):
- if self.download or not self["feedlist"].isValid():
- return
-
- self["job_progressbar"].value = 0
- self["job_progresslabel"].text = ""
-
- if to_where is None:
- if self.focus is self.LIST_SOURCE:
- to_where = self.LIST_DEST
- if self.focus is self.LIST_DEST:
- to_where = self.LIST_SOURCE
-
- if to_where is self.LIST_DEST:
- self.focus = self.LIST_DEST
- self["statusbar"].text = _("Please select target directory or medium")
- self["label_top"].text = _("choose destination directory")+":"
- self["feedlist"].hide()
- self["destlist"].show()
- self["label_bottom"].text = _("Selected source image")+":"
- self["path_bottom"].text = str(self["feedlist"].getNFIname())
- self["key_yellow"].text = (_("Select image"))
-
- elif to_where is self.LIST_SOURCE:
- self.focus = self.LIST_SOURCE
- self["statusbar"].text = _("Please choose .NFI image file from feed server to download")
- self["label_top"].text = _("select image from server")+":"
- self["feedlist"].show()
- self["destlist"].hide()
- self["label_bottom"].text = _("Destination directory")+":"
- self["path_bottom"].text = str(self["destlist"].getCurrentDirectory())
- self["key_yellow"].text = (_("Change dir."))
-
- def up(self):
- if self.download:
- return
- if self.focus is self.LIST_SOURCE:
- self["feedlist"].up()
- self.nfo_download()
- if self.focus is self.LIST_DEST:
- self["destlist"].up()
-
- def down(self):
- if self.download:
- return
- if self.focus is self.LIST_SOURCE:
- self["feedlist"].down()
- self.nfo_download()
- if self.focus is self.LIST_DEST:
- self["destlist"].down()
-
- def left(self):
- if self.download:
- return
- if self.focus is self.LIST_SOURCE:
- self["feedlist"].pageUp()
- self.nfo_download()
- if self.focus is self.LIST_DEST:
- self["destlist"].pageUp()
-
- def right(self):
- if self.download:
- return
- if self.focus is self.LIST_SOURCE:
- self["feedlist"].pageDown()
- self.nfo_download()
- if self.focus is self.LIST_DEST:
- self["destlist"].pageDown()
-
- def ok(self):
- if self.focus is self.LIST_SOURCE and self.nfo:
- self.session.open(NFOViewer, self.nfo)
- if self.download:
- return
- if self.focus is self.LIST_DEST:
- if self["destlist"].canDescent():
- self["destlist"].descent()
-
- def feed_download(self):
- self.downloading(True)
- self.download = self.feed_download
- client.getPage(self.feed_base).addCallback(self.feed_finished).addErrback(self.feed_failed)