adding the image upgrade wizard
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 5 Mar 2006 15:50:27 +0000 (15:50 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 5 Mar 2006 15:50:27 +0000 (15:50 +0000)
can backup settings to hdd, cf, usb or (in the future) a given path
recognizes the backup after flashing the image automatically and asks the user, if it should restore the settings
guides the user through the upgrade process

data/imagewizard.xml [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am
lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py
lib/python/Screens/ImageWizard.py [new file with mode: 0644]
lib/python/Screens/Makefile.am
mytest.py

diff --git a/data/imagewizard.xml b/data/imagewizard.xml
new file mode 100644 (file)
index 0000000..80943a8
--- /dev/null
@@ -0,0 +1,141 @@
+<wizard>
+               <step id="restorequestion">
+                       <condition>
+from Screens.ImageWizard import checkConfigBackup
+self.backuppath = checkConfigBackup()
+self.condition = (self.backuppath is not None)
+                       </condition>
+                       <text value="Do you want to restore your settings?" />
+                       <list>
+                               <listentry caption="Yes, restore the settings now" step="restore" />
+                               <listentry caption="No, just start my dreambox" step="end" />
+                       </list>
+               </step>
+
+               <step id="welcome">
+                       <text value="Welcome to the Image upgrade wizard. The wizard will assist you in upgrading the firmware of your Dreambox by providing a backup facility for your current settings and a short explanation of how to upgrade your firmware." />
+                       <list>
+                               <listentry caption="OK, guide me through the upgrade process" step="backupquestion" />
+                               <listentry caption="Exit the wizard" step="end" />
+                       </list>
+               </step>
+
+               <step id="backupquestion">
+                       <text value="The wizard can backup your current settings. Do you want to do a backup now?" />
+                       <list>
+                               <listentry caption="Yes, backup my settings!" step="backupwhere" />
+                               <listentry caption="No backup needed" step="upgrade" />
+                       </list>
+               </step>
+
+               <step id="backupwhere">
+                       <text value="Where do you want to backup your settings?" />
+                       <list>
+                               <listentry caption="Harddisk" step="hdd" />
+                               <listentry caption="Compact flash card" step="cf" />
+                               <listentry caption="USB" step="usb" />
+                               <listentry caption="Somewhere else" step="file" />
+                       </list>
+               </step>
+
+               <step id="hdd" nextstep="backup">
+                       <condition>
+from Components.Harddisk import harddiskmanager
+self.condition = harddiskmanager.HDDCount() > 0
+                       </condition>
+                       <text value="You have chosen to backup to your harddisk. Please press OK to start the backup now." />
+                       <code pos="after">
+self.backuppath = '/media/hdd/'
+                       </code>
+               </step>
+
+               <step id="hddfailed" nextstep="backupwhere">
+                       <condition>
+from Components.Harddisk import harddiskmanager
+self.condition = harddiskmanager.HDDCount() == 0
+                       </condition>
+                       <text value="You do not seem to have a harddisk in your Dreambox. So backing up to a harddisk is not an option for you." />
+               </step>
+               
+               <step id="cf" nextstep="backup">
+                       <text value="You have chosen to backup to a compact flash card. The card must be in the slot. We do not verify if it is really used at the moment. So better backup to the harddisk!\nPlease press OK to start the backup now." />
+                       <code pos="after">
+self.backuppath = '/media/cf/'
+                       </code>
+               </step>
+
+               <step id="usb" nextstep="backup">
+                       <text value="You have chosen to backup to an usb drive. Better backup to the harddisk!\nPlease press OK to start the backup now." />
+                       <code pos="after">
+self.backuppath = '/media/usb/'
+                       </code>
+               </step>
+
+               <step id="file" nextstep="backupwhere">
+                       <text value="This is unsupported at the moment." />
+               </step>
+
+               <step id="backup" nextstep="backupresult">
+                       <code>
+from Screens.ImageWizard import doBackup
+doBackup(self.backuppath)
+                       </code>
+                       <text value="Backup is done. Please press OK to see the result." />
+               </step>
+               
+               <step id="backupresult" nextstep="upgrade">
+                       <condition>
+from Screens.ImageWizard import checkConfigBackup
+self.backuppath = checkConfigBackup()
+self.condition = (self.backuppath is not None)
+                       </condition>
+                       <text value="Your backup succeeded. We will now continue to explain the further upgrade process." />
+               </step>
+
+               <step id="backupresultfailed" nextstep="backupwhere">
+                       <condition>
+from Screens.ImageWizard import checkConfigBackup
+self.backuppath = checkConfigBackup()
+self.condition = (self.backuppath is None)
+                       </condition>
+                       <text value="The backup failed. Please choose a different backup location." />
+               </step>
+               
+               <step id="restore" nextstep="activate">
+                       <code>
+from Screens.ImageWizard import doRestore
+doRestore(self.backuppath)
+                       </code>
+                       <text value="Restoring the settings is done. Please press OK to activate the restored settings now." />
+               </step>
+               
+               <step id="activate" nextstep="activate">
+                       <code>
+import os
+from Screens.ImageWizard import backupfile
+print 'mv ' + self.backuppath + backupfile + ' ' + self.backuppath + backupfile + '.old'
+os.system('mv ' + self.backuppath + backupfile + ' ' + self.backuppath + backupfile + '.old')
+os.system('killall enigma2') # ugly... no better solution atm
+                       </code>
+               </step>
+               
+               <step id="upgrade">
+                       <text value="You need a PC connected to your dreambox. If you need further instructions, please visit the website http://www.dm7025.de.\nYour dreambox will now be halted. After you have performed the update instructions from the website, your new firmware will ask you to restore your settings." />
+                       <list>
+                               <listentry caption="Yes, perform a shutdown now." step="shutdown" />
+                               <listentry caption="No, do nothing." step="end" />
+                       </list>
+               </step>
+
+               <step id="shutdown" nextstep="shutdown">
+                       <code>
+from enigma import quitMainloop
+quitMainloop(1)
+                       </code>
+                       <text value="Your dreambox is shutting down. Please stand by..." />
+               </step>
+               
+               <step id="end">
+                       <text value="The wizard is finished now." />
+               </step>
+</wizard>
index 7b26d5f9a65c6014b4f5d45736c888b5e15f10a3..9848f3dfe48d1becc154bd17b36542a78b8738f2 100644 (file)
@@ -3,5 +3,6 @@ installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/SoftwareUpdate
 install_PYTHON =       \
        __init__.py \
        plugin.py       \
 install_PYTHON =       \
        __init__.py \
        plugin.py       \
-       update.png
+       update.png 
+
  
  
index c065c8157b0c2888385c9595a22ee5c3f55017bb..00f8e18527281e8ea5e74e5dd6751961d36359c1 100644 (file)
@@ -8,6 +8,7 @@ from Components.MenuList import MenuList
 from Components.Input import Input
 from Screens.Console import Console
 from Plugins.Plugin import PluginDescriptor
 from Components.Input import Input
 from Screens.Console import Console
 from Plugins.Plugin import PluginDescriptor
+from Screens.ImageWizard import ImageWizard
 
 import os
 
 
 import os
 
@@ -25,7 +26,8 @@ class UpdatePluginMenu(Screen):
                
                list = []
                if self.menu == 0:
                
                list = []
                if self.menu == 0:
-                       list.append((_("Upgrade"), "upgrade"))
+                       list.append((_("Image-Upgrade"), "image"))
+                       list.append((_("Online-Upgrade"), "upgrade"))
                        list.append((_("Advanced"), "advanced"))
                elif self.menu == 1:
                        list.append((_("Choose source"), "source"))
                        list.append((_("Advanced"), "advanced"))
                elif self.menu == 1:
                        list.append((_("Choose source"), "source"))
@@ -42,6 +44,8 @@ class UpdatePluginMenu(Screen):
                
        def go(self):
                if self.menu == 0:
                
        def go(self):
                if self.menu == 0:
+                       if (self["menu"].l.getCurrentSelection()[1] == "image"):
+                               self.session.open(ImageWizard)
                        if (self["menu"].l.getCurrentSelection()[1] == "upgrade"):
                                self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
                        if (self["menu"].l.getCurrentSelection()[1] == "advanced"):
                        if (self["menu"].l.getCurrentSelection()[1] == "upgrade"):
                                self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
                        if (self["menu"].l.getCurrentSelection()[1] == "advanced"):
diff --git a/lib/python/Screens/ImageWizard.py b/lib/python/Screens/ImageWizard.py
new file mode 100644 (file)
index 0000000..f96ddad
--- /dev/null
@@ -0,0 +1,50 @@
+from Wizard import Wizard, wizardManager
+
+from Components.config import configElementBoolean, config
+from Components.Pixmap import *
+
+from LanguageSelection import LanguageSelection
+from Tools.Directories import fileExists
+
+import os
+
+backupfile = "backupenigma2settings.tar"
+
+def checkConfigBackup():
+       paths = ['/media/hdd/', '/media/cf/']
+       for x in paths:
+               if fileExists(x + backupfile):
+                       return x
+       return None
+
+if checkConfigBackup() is None:
+       backupAvailable = 0
+else:
+       backupAvailable = 1
+
+class ImageWizard(Wizard):
+       skin = """
+               <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder">
+                       <widget name="text" position="50,100" size="440,250" font="Regular;23" />
+                       <widget name="list" position="50,350" zPosition="1" size="440,200" />
+                       <widget name="config" position="50,350" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />
+               </screen>"""
+       
+       def __init__(self, session):
+               self.xmlfile = "imagewizard.xml"
+               
+               Wizard.__init__(self, session, showSteps=False, showStepSlider=False, showList=True, showConfig=True)
+               
+       def markDone(self):
+               pass
+
+wizardManager.registerWizard(ImageWizard, backupAvailable)
+
+def doBackup(path):
+       os.system('tar cvpf ' + path + backupfile + ' /etc/enigma2')
+
+def doRestore(path):
+       os.system('cd / && tar xvpf ' + path + backupfile + ' etc/enigma2')
+       
+
+               
\ No newline at end of file
index d917eb39aa065de9723670b98bb540fb4ffec4ae..7a30e88aee374993738ba09a9977d24fb1afe579 100644 (file)
@@ -9,4 +9,4 @@ install_PYTHON = \
        AudioSelection.py InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \
        Dish.py SubserviceSelection.py LanguageSelection.py StartWizard.py \
        TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \
        AudioSelection.py InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \
        Dish.py SubserviceSelection.py LanguageSelection.py StartWizard.py \
        TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \
-       Console.py InputBox.py ChoiceBox.py SimpleSummary.py
+       Console.py InputBox.py ChoiceBox.py SimpleSummary.py ImageWizard.py
index 77e925b6a5d2ec48f6d2ff0853d88f6beba56892..680f198d35f58808297c0899a60db30812388234 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -39,6 +39,7 @@ except ImportError:
 from Components.PluginComponent import plugins
 
 from Screens.Wizard import wizardManager
 from Components.PluginComponent import plugins
 
 from Screens.Wizard import wizardManager
+from Screens.ImageWizard import *
 from Screens.StartWizard import *
 from Screens.TutorialWizard import *
 from Tools.BoundFunction import boundFunction
 from Screens.StartWizard import *
 from Screens.TutorialWizard import *
 from Tools.BoundFunction import boundFunction