- def md5finished(self, retval):
- print "[md5finished]: " + str(retval)
- self.download_container.appClosed.remove(self.md5finished)
- if retval==0:
- self.downloading(False)
- if self.wizard_mode:
- self.configBackup()
- else:
- self["statusbar"].text = _(".NFI file passed md5sum signature check. You can safely flash this image!")
- self.switchList(self.LIST_SOURCE)
- else:
- self.session.openWithCallback(self.nfi_remove, MessageBox, (_("The md5sum validation failed, the file may be downloaded incompletely or be corrupted!") + "\n" + _("Remove the broken .NFI file?")), MessageBox.TYPE_YESNO)
-
- def nfi_remove(self, answer):
- self.downloading(False)
- if answer == True:
- nfifilename = self["destlist"].getCurrentDirectory()+'/'+self["feedlist"].getNFIname()
- if fileExists(self.nfofilename):
- remove(self.nfofilename)
- if fileExists(nfifilename):
- remove(nfifilename)
- self.switchList(self.LIST_SOURCE)
-
- def askCreateUSBstick(self):
- self.downloading()
- self.imagefilename = "/tmp/nfiflash_" + self.box + ".img"
- message = _("You have chosen to create a new .NFI flasher bootable USB stick. This will repartition the USB stick and therefore all data on it will be erased.")
- self.session.openWithCallback(self.flasherdownload_query, MessageBox, (message + '\n' + _("First we need to download the latest boot environment for the USB flasher.")), MessageBox.TYPE_YESNO)
-
- def flasherdownload_query(self, answer):
- if answer is False:
- self.downloading(False)
- self.switchList(self.LIST_SOURCE)
- return
- #url = self.feed_base + "/nfiflasher_" + self.box + ".tar.bz2"
- url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s.tar.bz2" % self.box
- localfile = "/tmp/nfiflasher_image.tar.bz2"
- print "[flasherdownload_query] downloading %s to %s" % (url, localfile)
- self["statusbar"].text = ("Downloading %s..." % url)
- self.download = downloadWithProgress(url,localfile)
- self.download.addProgress(self.nfi_progress)
- self["job_progressbar"].range = 1000
- self.download.start().addCallback(self.flasherdownload_finished).addErrback(self.flasherdownload_failed)
-
- def flasherdownload_failed(self, failure_instance=None, error_message=""):
- if error_message == "" and failure_instance is not None:
- error_message = failure_instance.getErrorMessage()
- print "[flasherdownload_failed] " + error_message
- message = "%s %s" % (_("Download of USB flasher boot image failed: "),error_message)
- self.session.open(MessageBox, message, MessageBox.TYPE_ERROR)
- self.remove_img(True)
-
- def flasherdownload_finished(self, string=""):
- print "[flasherdownload_finished] " + str(string)
+ def exit(self):
+ self.close(False)
+
+(ALLIMAGES, RELEASE, EXPERIMENTAL, STICK_WIZARD, START) = range(5)
+
+class NFIDownload(Screen):
+ skin = """
+ <screen name="NFIDownload" position="center,center" size="610,410" title="NFIDownload" >
+ <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#9f1313" transparent="1" />
+ <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+ <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1" />
+ <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1" />
+ <ePixmap pixmap="skin_default/border_menu_350.png" position="5,50" zPosition="1" size="350,300" transparent="1" alphatest="on" />
+ <widget source="menu" render="Listbox" position="15,60" size="330,290" scrollbarMode="showOnDemand">
+ <convert type="TemplatedMultiContent">
+ {"templates":
+ {"default": (25, [
+ MultiContentEntryText(pos = (2, 2), size = (330, 24), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText,
+ ], True, "showOnDemand")
+ },
+ "fonts": [gFont("Regular", 22)],
+ "itemHeight": 25
+ }
+ </convert>
+ </widget>
+ <widget source="menu" render="Listbox" position="360,50" size="240,300" scrollbarMode="showNever" selectionDisabled="1">
+ <convert type="TemplatedMultiContent">
+ {"templates":
+ {"default": (300, [
+ MultiContentEntryText(pos = (2, 2), size = (240, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description,
+ ], False, "showNever")
+ },
+ "fonts": [gFont("Regular", 22)],
+ "itemHeight": 300
+ }
+ </convert>
+ </widget>
+ <widget source="status" render="Label" position="5,360" zPosition="10" size="600,50" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
+ </screen>"""
+
+ def __init__(self, session, destdir=None):
+ Screen.__init__(self, session)
+ #self.skin_path = plugin_path
+ #self.menu = args
+
+ self.box = HardwareInfo().get_device_name()
+ self.feed_base = "http://www.dreamboxupdate.com/opendreambox" #/1.5/%s/images/" % self.box
+ self.usbmountpoint = "/mnt/usb/"
+
+ self.menulist = []
+
+ self["menu"] = List(self.menulist)
+ self["key_red"] = StaticText(_("Close"))
+ self["key_green"] = StaticText()
+ self["key_yellow"] = StaticText()
+ self["key_blue"] = StaticText()
+
+ self["status"] = StaticText(_("Please wait... Loading list..."))
+
+ self["shortcuts"] = ActionMap(["OkCancelActions", "ColorActions", "ShortcutActions", "DirectionActions"],
+ {
+ "ok": self.keyOk,
+ "green": self.keyOk,
+ "red": self.keyRed,
+ "blue": self.keyBlue,
+ "up": self.keyUp,
+ "upRepeated": self.keyUp,
+ "downRepeated": self.keyDown,
+ "down": self.keyDown,
+ "cancel": self.close,
+ }, -1)
+ self.onShown.append(self.go)
+ self.feedlists = [[],[],[]]
+ self.branch = START