lots of improvements in the default wizard
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 16 May 2008 23:08:45 +0000 (23:08 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 16 May 2008 23:08:45 +0000 (23:08 +0000)
data/defaultwizard.xml
lib/python/Components/DreamInfoHandler.py
lib/python/Screens/DefaultWizard.py

index a8409b7..e29963b 100644 (file)
@@ -1,27 +1,61 @@
 <wizard>
-       <step id="welcome" nextstep="end">
+       <step id="welcome" nextstep="nothingtoinstall">
                <condition>
 packagelist = self.fillPackagesList()
-self.condition = (len(packagelist) > 1)
+self.runWizard = (len(packagelist) > 0)
+self.condition = self.runWizard
                </condition>
-               <text value="Default-Wizard" />
-               <list type="dynamic" source="listDefaults" evaluation="selectionMade" />
+               <text value="You can choose some default settings now. Please select the settings you want to be installed." />
+               <!--list type="dynamic" source="listDefaults" evaluation="selectionMade" /-->
+               <config type="dynamic" source="getConfigList" evaluation="selectionMade" />
                <code pos="after">
 self.disableKeys = True
                </code>
        </step>
-       <step id="end">
+       <step id="nopackages" nextstep="install">
+               <condition>
+self.condition = self.runWizard or not self.silent
+               </condition>
+               <text value="There are no default settings in your image." />
+       </step>
+       
+       <step id="nothingtoinstall" nextstep="install">
+               <condition>
+if self.runWizard:
+       self.condition = True
+       for x in self.packagesConfig:
+               if x.value:
+                       self.condition = False
+                       break
+else:
+       self.condition = False
+               </condition>
+               <text value="You chose not to install any default settings. You can however install the default settings later in the settings menu." />
+               <!--list type="dynamic" source="listDefaults" evaluation="selectionMade" /-->
                <code>
-self.disableKeys = True                        
+self.disableKeys = False
+               </code>
+               <code pos="after">
+self.markDone()
                </code>
+       </step>
+       
+       <step id="install">
                <condition>
-packagelist = self.fillPackagesList()
-self.condition = (len(packagelist) > 0)
-               </condition>            
+self.condition = False
+if self.runWizard:
+       for x in self.packagesConfig:
+               if x.value:
+                       self.condition = True
+                       break 
+               </condition>
+               <code>
+self.disableKeys = True                        
+               </code>
                <code>
-print "len of packageslist", len(self.packageslist)
-if (len(self.packageslist) == 1):
-       self.installPackage(0)
+#print "len of packageslist", len(self.packageslist)
+#if (len(self.packageslist) == 1):
+       #self.installPackage(0)
                </code>
                <text value="Installing defaults... Please wait..." />
        </step>
index cc07160..8220b8b 100644 (file)
@@ -97,9 +97,15 @@ class DreamInfoHandler:
        STATUS_ERROR = 2
        STATUS_INIT = 4
        
-       def __init__(self, statusCallback):
+       def __init__(self, statusCallback, blocking = False):
                self.directory = "/"
                
+               # caution: blocking should only be used, if further execution in enigma2 depends on the outcome of
+               # the installer!
+               self.blocking = blocking
+               
+               self.currentlyInstallingMetaIndex = None
+               
                self.console = eConsoleAppContainer()
                self.console.appClosed.get().append(self.installNext)
                
@@ -107,7 +113,7 @@ class DreamInfoHandler:
                self.setStatus(self.STATUS_INIT)
                                
                self.packageslist = []
-       
+                       
        def readInfo(self, directory, file):
                print "Reading .info file", file
                handler = InfoHandler(self.prerequisiteMet, directory)
@@ -146,7 +152,17 @@ class DreamInfoHandler:
                                # TODO: hardware detection
                                met = True
                return True
-                       
+       
+       def installPackages(self, indexes):
+               print "installing packages", indexes
+               if len(indexes) == 0:
+                       self.setStatus(self.STATUS_DONE)
+                       return
+               self.installIndexes = indexes
+               print "+++++++++++++++++++++++bla"
+               self.currentlyInstallingMetaIndex = 0
+               self.installPackage(self.installIndexes[self.currentlyInstallingMetaIndex])
+
        def installPackage(self, index):
                print "installing package with index", index, "and name", self.packageslist[index][0]["attributes"]["name"]
                
@@ -164,10 +180,15 @@ class DreamInfoHandler:
        def installNext(self, *args, **kwargs):
                self.currentIndex += 1
                attributes = self.installingAttributes
+               #print "attributes:", attributes
                
-               if self.currentAttributeIndex >= len(self.attributeNames): # end reached
-                       self.setStatus(self.STATUS_DONE)
-                       return
+               if self.currentAttributeIndex >= len(self.attributeNames): # end of package reached
+                       if self.currentlyInstallingMetaIndex is None or self.currentlyInstallingMetaIndex >= len(self.installIndexes) - 1:
+                               self.setStatus(self.STATUS_DONE)
+                               return
+                       else:
+                               self.currentlyInstallingMetaIndex += 1
+                               self.installPackage(self.installIndexes[self.currentlyInstallingMetaIndex])
                
                self.setStatus(self.STATUS_WORKING)             
                
@@ -221,9 +242,13 @@ class DreamInfoHandler:
                self.installNext()
                
        def installIPK(self, directory, name):
-               self.ipkg = IpkgComponent()
-               self.ipkg.addCallback(self.ipkgCallback)
-               self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': directory + name})
+               if self.blocking:
+                       os.system("ipkg install " + directory + name)
+                       self.installNext()
+               else:
+                       self.ipkg = IpkgComponent()
+                       self.ipkg.addCallback(self.ipkgCallback)
+                       self.ipkg.startCmd(IpkgComponent.CMD_INSTALL, {'package': directory + name})
                
        def ipkgCallback(self, event, param):
                print "ipkgCallback"
@@ -235,9 +260,13 @@ class DreamInfoHandler:
        def installSkin(self, directory, name):
                print "installing skin:", directory, " - ", name
                print "cp -a %s %s" % (directory, resolveFilename(SCOPE_SKIN))
-               if self.console.execute("cp -a %s %s" % (directory, resolveFilename(SCOPE_SKIN))):
-                       print "execute failed"
+               if self.blocking:
+                       os.system("cp -a %s %s" % (directory, resolveFilename(SCOPE_SKIN)))
                        self.installNext()
+               else:
+                       if self.console.execute("cp -a %s %s" % (directory, resolveFilename(SCOPE_SKIN))):
+                               print "execute failed"
+                               self.installNext()
 
        def mergeServices(self, directory, name, merge = False):
                print "merging services:", directory, " - ", name
@@ -251,6 +280,10 @@ class DreamInfoHandler:
        def installFavourites(self, directory, name):
                print "installing favourites:", directory, " - ", name
 
-               if self.console.execute("cp %s %s" % ((directory + name), resolveFilename(SCOPE_CONFIG))):
-                       print "execute failed"
+               if self.blocking:
+                       os.system("cp %s %s" % ((directory + name), resolveFilename(SCOPE_CONFIG)))
                        self.installNext()
+               else:
+                       if self.console.execute("cp %s %s" % ((directory + name), resolveFilename(SCOPE_CONFIG))):
+                               print "execute failed"
+                               self.installNext()
index 5d274b0..87f6816 100644 (file)
@@ -1,8 +1,9 @@
-from Wizard import Wizard, wizardManager
-from Tools.Directories import crawlDirectory, resolveFilename, SCOPE_DEFAULTDIR
+from Wizard import wizardManager
+from Screens.WizardLanguage import WizardLanguage
+from Tools.Directories import crawlDirectory, resolveFilename, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTPARTITION
 
 from Components.Pixmap import Pixmap, MovingPixmap
-from Components.config import config, ConfigBoolean, configfile
+from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, getConfigListEntry
 from Components.DreamInfoHandler import DreamInfoHandler, InfoHandler, InfoHandlerParseError
 import os
 
@@ -10,13 +11,15 @@ config.misc.defaultchosen = ConfigBoolean(default = True)
 
 import xml.sax
 
-class DefaultWizard(Wizard, DreamInfoHandler):
-       def __init__(self, session):
+class DefaultWizard(WizardLanguage, DreamInfoHandler):
+       def __init__(self, session, silent = True):
                DreamInfoHandler.__init__(self, self.statusCallback)
-               self.directory = resolveFilename(SCOPE_DEFAULTDIR)
+               self.silent = silent
+               os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
+               self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
                self.xmlfile = "defaultwizard.xml"
         
-               Wizard.__init__(self, session, showSteps = False)
+               WizardLanguage.__init__(self, session, showSteps = False)
                self["wizard"] = Pixmap()
                self["rc"] = MovingPixmap()
                self["arrowdown"] = MovingPixmap()
@@ -31,19 +34,42 @@ class DefaultWizard(Wizard, DreamInfoHandler):
        def statusCallback(self, status, progress):
                print "statusCallback:", status, progress
                if status == DreamInfoHandler.STATUS_DONE:
-                       self["text"].setText(_("Finished"))
+                       self["text"].setText(_("The installation of the default settings is finished. You can now continue configuring your Dreambox by pressing the OK button on the remote control."))
                        self.markDone()
-                       os.system("killall -9 enigma2")
+                       self.disableKeys = False
 
-       def listDefaults(self):
+       def getConfigList(self):
                self.packageslist = []
+               configList = []
                self.fillPackagesList()
-               list = []
+               self.packagesConfig = []
                for x in range(len(self.packageslist)):
-                       list.append((self.packageslist[x][0]["attributes"]["name"], str(x)))
-               print "defaults list:", list
-               return list
-    
-       def selectionMade(self, index):
-               print "selected:", index
-               self.installPackage(int(index))
\ No newline at end of file
+                       entry = ConfigYesNo()
+                       self.packagesConfig.append(entry)
+                       configList.append(getConfigListEntry(self.packageslist[x][0]["attributes"]["name"], entry))
+               return configList
+
+       def selectionMade(self):
+               print "selection made"
+               #self.installPackage(int(index))
+               indexList = []
+               for x in range(len(self.packagesConfig)):
+                       if self.packagesConfig[x].value:
+                               indexList.append(x)
+               self.installPackages(indexList)
+               
+class ImageDefaultInstaller(DreamInfoHandler):
+       def __init__(self):
+               DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
+               self.directory = resolveFilename(SCOPE_DEFAULTDIR)
+               self.fillPackagesList()
+               self.installPackage(0)
+               
+       def statusCallback(self, status, progress):
+               pass
+               
+wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
+if config.misc.defaultchosen.value:
+       print "Installing image defaults"
+       installer = ImageDefaultInstaller()
+       print "installing done!"