From: Fraxinas Date: Mon, 1 Feb 2010 22:30:36 +0000 (+0100) Subject: fix screen layout, add configuration restore wizard code in flasher and fix crash... X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=04d23246dd5c88df949d523e0c149be8070a0a96 fix screen layout, add configuration restore wizard code in flasher and fix crash when trying to use wizard with no .nfo file present, fixes bug #394 --- diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index 860efc0..8986560 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -63,10 +63,10 @@ class NFIFlash(Screen): - - - - + + + + @@ -95,6 +95,7 @@ class NFIFlash(Screen): { "green": self.ok, "yellow": self.reboot, + "blue": self.runWizard, "ok": self.ok, "left": self.left, "right": self.right, @@ -109,6 +110,43 @@ class NFIFlash(Screen): self.md5sum = "" self.job = None self.box = HardwareInfo().get_device_name() + self.configuration_restorable = None + self.wizard_mode = False + from enigma import eTimer + self.delayTimer = eTimer() + self.delayTimer.callback.append(self.runWizard) + self.delayTimer.start(50,1) + + def check_for_wizard(self): + if self["filelist"].getCurrentDirectory() is not None and fileExists(self["filelist"].getCurrentDirectory()+"wizard.nfo"): + self["key_blue"].text = _("USB stick wizard") + return True + else: + self["key_blue"].text = "" + return False + + def runWizard(self): + if not self.check_for_wizard(): + self.wizard_mode = False + return + wizardcontent = open(self["filelist"].getCurrentDirectory()+"/wizard.nfo", "r").readlines() + nfifile = None + for line in wizardcontent: + line = line.strip() + if line.startswith("image: "): + nfifile = self["filelist"].getCurrentDirectory()+line[7:] + if line.startswith("configuration: "): + backupfile = self["filelist"].getCurrentDirectory()+line[15:] + if fileExists(backupfile): + print "wizard configuration:", backupfile + self.configuration_restorable = backupfile + else: + self.configuration_restorable = None + if nfifile and fileExists(nfifile): + self.wizard_mode = True + print "wizard image:", nfifile + self.check_for_NFO(nfifile) + self.queryFlash() def closeCB(self): if ( self.job is None or self.job.status is not self.job.IN_PROGRESS ) and not self.no_autostart: @@ -133,12 +171,16 @@ class NFIFlash(Screen): self["filelist"].pageUp() self.check_for_NFO() - def check_for_NFO(self): + def check_for_NFO(self, nfifile=None): self.session.summary.setText(self["filelist"].getFilename()) - if self["filelist"].getFilename() is None: - return - if self["filelist"].getCurrentDirectory() is not None: - self.nfifile = self["filelist"].getCurrentDirectory()+self["filelist"].getFilename() + if nfifile is None: + self.session.summary.setText(self["filelist"].getFilename()) + if self["filelist"].getFilename() is None: + return + if self["filelist"].getCurrentDirectory() is not None: + self.nfifile = self["filelist"].getCurrentDirectory()+self["filelist"].getFilename() + else: + self.nfifile = nfifile if self.nfifile.upper().endswith(".NFI"): self["key_green"].text = _("Flash") @@ -152,7 +194,7 @@ class NFIFlash(Screen): else: self.md5sum = "" else: - self["infolabel"].text = _("No details for this image file") + ":\n" + self["filelist"].getFilename() + self["infolabel"].text = _("No details for this image file") + (self["filelist"].getFilename() or "") self.md5sum = "" else: self["infolabel"].text = "" @@ -164,6 +206,7 @@ class NFIFlash(Screen): self["filelist"].descent() self.session.summary.setText(self["filelist"].getFilename()) self.check_for_NFO() + self.check_for_wizard() else: self.queryFlash() @@ -192,7 +235,10 @@ class NFIFlash(Screen): def md5finished(self, retval): if retval==0: - self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO) + if self.wizard_mode: + self.session.openWithCallback(self.queryCB, MessageBox, _("Shall the USB stick wizard proceed and program the image file %s into flash memory?" % self.nfifile.rsplit('/',1)[-1]), MessageBox.TYPE_YESNO) + else: + self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO) else: self.session.openWithCallback(self.queryCB, MessageBox, _("The md5sum validation failed, the file may be corrupted! Are you sure that you want to burn this image to flash memory? You are doing this at your own risk!"), MessageBox.TYPE_YESNO) @@ -201,6 +247,7 @@ class NFIFlash(Screen): self.createJob() else: self["statusbar"].text = _("Please select .NFI flash image file from medium") + self.wizard_mode = False def createJob(self): self.job = Job("Image flashing job") @@ -240,6 +287,8 @@ class NFIFlash(Screen): elif j.status == j.FINISHED: self["statusbar"].text = _("Writing NFI image file to flash completed") self.session.summary.setText(_("NFI image flashing completed. Press Yellow to Reboot!")) + if self.wizard_mode: + self.restoreConfiguration() self["key_yellow"].text = _("Reboot") elif j.status == j.FAILED: @@ -250,10 +299,19 @@ class NFIFlash(Screen): print "[jobcb] %s %s %s" % (jobref, fasel, blubber) self["key_green"].text = _("Flash") - def reboot(self): + def reboot(self, ret=None): if self.job.status == self.job.FINISHED: self["statusbar"].text = ("rebooting...") TryQuitMainloop(self.session,2) - + + def restoreConfiguration(self): + if self.configuration_restorable: + from Screens.Console import Console + cmdlist = [ "mount /dev/mtdblock/3 /mnt/realroot -t jffs2", "tar -xzvf " + self.configuration_restorable + " -C /mnt/realroot/" ] + self.session.open(Console, title = "Restore running", cmdlist = cmdlist, finishedCallback = self.restore_finished, closeOnSuccess = True) + + def restore_finished(self): + self.session.openWithCallback(self.reboot, MessageBox, _("USB stick wizard finished. Your dreambox will now restart with your new image!"), MessageBox.TYPE_INFO) + def createSummary(self): return NFISummary