Merge branch 'bug_480_nfiflash' into experimental
authorFraxinas <andreas.frisch@multimedia-labs.de>
Tue, 7 Sep 2010 12:07:54 +0000 (14:07 +0200)
committerFraxinas <andreas.frisch@multimedia-labs.de>
Tue, 7 Sep 2010 12:07:54 +0000 (14:07 +0200)
lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py

index 27038e6..296d3bc 100644 (file)
@@ -215,7 +215,7 @@ class CopyTask(Task):
 
 class NFOViewer(Screen):
        skin = """
-               <screen name="NFOViewer" position="center,center" size="610,410" title="Changelog viewer" >
+               <screen name="NFOViewer" position="center,center" size="610,410" title="Changelog" >
                        <widget name="changelog" position="10,10" size="590,380" font="Regular;16" />
                </screen>"""
 
@@ -631,7 +631,7 @@ class NFIDownload(Screen):
                        self.showHint()
 
        def showHint(self, ret=None):
-               self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO)
+               self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and make sure the bootable USB stick is plugged in.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO)
                self.umountCallback = self.keyRed
                self.umount()
 
@@ -690,8 +690,8 @@ class NFIDownload(Screen):
 
        def askStartWizard(self):
                self.branch = STICK_WIZARD
-               message = _("""This plugin creates a USB stick which can be used to update the firmware of your Dreambox in case it has no network connection or only WLAN access.
-First, you need to prepare a USB stick so that it is bootable.
+               message = _("""This plugin creates a USB stick which can be used to update the firmware of your Dreambox without the need for a network or WLAN connection.
+First, a USB stick needs to be prepared so that it becomes bootable.
 In the next step, an NFI image file can be downloaded from the update server and saved on the USB stick.
 If you already have a prepared bootable USB stick, please insert it now. Otherwise plug in a USB stick with a minimum size of 64 MB!""")
                self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/","/autofs/sda1/","/media/hdd/","/media/net/",self.usbmountpoint,"/media/dvd/"])
@@ -753,7 +753,7 @@ If you already have a prepared bootable USB stick, please insert it now. Otherwi
 
        def nfo_finished(self,nfodata=""):
                print "[nfo_finished] " + str(nfodata)
-               self["key_blue"].text = _("Changelog viewer")
+               self["key_blue"].text = _("Changelog")
                self.nfo = nfodata
 
        def md5verify(self, md5, path):
index 95c7eee..ba96c07 100755 (executable)
@@ -2,6 +2,7 @@ from Screens.Screen import Screen
 from Screens.MessageBox import MessageBox
 from Screens.ChoiceBox import ChoiceBox
 from Screens.Standby import TryQuitMainloop
+from Screens.Console import Console
 from Components.ActionMap import ActionMap
 from Components.Sources.StaticText import StaticText
 from Components.Sources.Progress import Progress
@@ -13,7 +14,7 @@ from Screens.TaskView import JobView
 from Tools.Directories import fileExists
 from Tools.HardwareInfo import HardwareInfo
 from os import system
-from enigma import eConsoleAppContainer
+from enigma import eConsoleAppContainer, quitMainloop
 from Components.About import about
 
 class md5Postcondition(Condition):
@@ -95,11 +96,11 @@ class NFIFlash(Screen):
                self["key_green"] = StaticText()
                self["key_yellow"] = StaticText()
                self["key_blue"] = StaticText()
-               self.filelist = FileList(self.usbmountpoint, matchingPattern = "^.*\.(nfi|NFI)")
+               self.filelist = FileList(self.usbmountpoint, matchingPattern = "^.*\.(nfi|NFI)", showDirectories = False, showMountpoints = False)
                self["filelist"] = self.filelist
-               self["infolabel"] = StaticText("")
+               self["infolabel"] = StaticText()
 
-               self["status"] = StaticText("currently installed image: %s" % (about.getImageVersionString()))
+               self["status"] = StaticText(_("Please select an NFI file and press green key to flash!") + '\n' + _("currently installed image: %s") % (about.getImageVersionString()))
                self.job = None
 
                self["shortcuts"] = ActionMap(["OkCancelActions", "ColorActions", "ShortcutActions", "DirectionActions"],
@@ -115,6 +116,15 @@ class NFIFlash(Screen):
                        "right": self.keyRight
                }, -1)
                self.md5sum = ""
+               self.onShown.append(self.autostart)
+
+       def autostart(self):
+               self.onShown.remove(self.autostart)
+               self.check_for_NFO()
+               print "[[layoutFinished]]", len(self["filelist"].getFileList())
+               if len(self["filelist"].getFileList()) == 1:
+                       print "==1"
+                       self.keyOk()
 
        def keyUp(self):
                self["filelist"].up()
@@ -176,6 +186,7 @@ class NFIFlash(Screen):
 
        def createJob(self):
                self.job = Job("Image flashing job")
+               self.job.afterEvent = "close"
                cwd = self["filelist"].getCurrentDirectory()
                md5verify(self.job, cwd, self.md5sum)
                writeNAND(self.job, [self.nfifile], self.box)
@@ -183,13 +194,36 @@ class NFIFlash(Screen):
                self["key_yellow"].text = ""
                self["key_green"].text = ""
                job_manager.AddJob(self.job)
-               self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False)
+               self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False, afterEventChangeable = False)
 
        def flashed(self, bg):
                print "[flashed]"
-               self["key_yellow"].text = _("Reboot")
+               if self.job.status == self.job.FINISHED:
+                       self["status"].text = _("NFI image flashing completed. Press Yellow to Reboot!")
+                       filename = self.usbmountpoint+'enigma2settingsbackup.tar.gz'
+                       if fileExists(filename):
+                               import os.path, time
+                               date = time.ctime(os.path.getmtime(filename))
+                               self.session.openWithCallback(self.askRestoreCB, MessageBox, _("The wizard found a configuration backup. Do you want to restore your old settings from %s?") % date, MessageBox.TYPE_YESNO)
+                       else:
+                               self.unlockRebootButton()
+               else:
+                       self["status"].text = _("Flashing failed")
+
+       def askRestoreCB(self, ret):
+               if ret:
+                       from Plugins.SystemPlugins.SoftwareManager.BackupRestore import getBackupFilename
+                       restorecmd = ["tar -xzvf " + self.usbmountpoint + getBackupFilename() + " -C /"]
+                       self.session.openWithCallback(self.unlockRebootButton, Console, title = _("Restore is running..."), cmdlist = restorecmd, closeOnSuccess = True)
+               else:
+                       self.unlockRebootButton()
+
+       def unlockRebootButton(self, retval = None):
+               if self.job.status == self.job.FINISHED:
+                       self["key_yellow"].text = _("Reboot")
 
        def reboot(self, ret=None):
                if self.job.status == self.job.FINISHED:
                        self["status"].text = ("rebooting...")
-                       TryQuitMainloop(self.session,2)
+                       from os import system
+                       system("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/kill_e2_reboot.sh")