Enigma2: add CleanupWizard to SystemPlugins and Enigma2 build.
authoracid-burn <acidburn@opendreambox.org>
Thu, 27 Aug 2009 15:38:58 +0000 (17:38 +0200)
committeracid-burn <acidburn@opendreambox.org>
Thu, 27 Aug 2009 15:38:58 +0000 (17:38 +0200)
- The CleanupWizard informs you on system boot if your avalalble internal memory (flash) has droppen below 2MB
  and allows the removal of enigma2-plugins and skins to cleanup the internal memory (flash) on bootup.

configure.ac
lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/LICENSE [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/Makefile.am [changed mode: 0644->0755]
po/Makefile.am

index 1a2d1e0..fea6a0d 100755 (executable)
@@ -140,6 +140,8 @@ lib/python/Plugins/Extensions/SocketMMI/meta/Makefile
 lib/python/Plugins/Extensions/SocketMMI/src/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/meta/Makefile
 lib/python/Plugins/Extensions/SocketMMI/src/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/meta/Makefile
+lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile
+lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile
 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile
 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/Makefile
 lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/Makefile
 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile
 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/Makefile
 lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/Makefile
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py
new file mode 100755 (executable)
index 0000000..d8de354
--- /dev/null
@@ -0,0 +1,172 @@
+from Screens.Wizard import wizardManager, WizardSummary
+from Screens.WizardLanguage import WizardLanguage
+from Screens.Rc import Rc
+from Screens.Console import Console
+from Screens.MessageBox import MessageBox
+from Components.Console import Console
+from Components.Ipkg import IpkgComponent
+from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigBoolean
+from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from os import system, statvfs, stat
+
+
+def checkFreeSpaceAvailable():
+       try:
+               stat = statvfs('/')
+       except OSError:
+               return None
+       return (stat.f_bfree * stat.f_bsize)/1024 #return free space in kiloBytes
+
+
+class CleanupWizard(WizardLanguage, Rc):
+
+       skin = """
+               <screen name="CleanupWizard" position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
+                       <widget name="text" position="153,40" size="380,330" font="Regular;22" />
+                       <widget source="list" render="Listbox" position="43,300" size="460,220" scrollbarMode="showOnDemand" >
+                               <convert type="StringList" />
+                       </widget>
+                       <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" />
+                       <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
+                       <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
+                       <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" />
+                       <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="530,50" zPosition="10" size="154,500" alphatest="on" />
+                       <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
+                       <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
+                       <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
+                       <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
+               </screen>"""
+
+       def __init__(self, session):
+               self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/CleanupWizard/cleanupwizard.xml")
+               WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
+               Rc.__init__(self)
+               self.session = session
+               self["wizard"] = Pixmap()
+               self.selectedAction = None
+               self.selectedPackage = None
+               self.NextStep = None
+               self.Text = None
+               self.buildListRef = None
+               self.RemoveRef = None
+               self.excluded_extensions = ('-skins', '-streamproxy', '-frontprocessorupgrade', '-crashlogautosubmit', '-hotplug', '-webinterface', '-mediascanner', '-genuinedreambox', '-mediaplayer', '-pictureplayer', '-dvdplayer', '-dvdburn', '-videotune', '-videomode', '-softwaremanager', '-skinselector', '-satfinder' )
+               self.Console = Console()
+               self.installed_packetlist = []
+               self.ipkg = IpkgComponent()
+               self.ipkg.addCallback(self.ipkgCallback)
+
+       def markDone(self):
+               pass
+
+       def listAction(self):
+               list = []
+               list.append((_("OK, remove some extensions"), "removeextensions"))
+               list.append((_("Exit the cleanup wizard"), "end"))
+               return list
+
+       def listAgainAction(self):
+               list = []
+               list.append((_("OK, remove another extensions"), "removeextensions"))
+               list.append((_("Exit the cleanup wizard"), "end"))
+               return list
+
+       def ActionSelectionMade(self, index):
+               self.selectedAction = index
+               self.ActionSelect(index)
+
+       def ActionSelect(self, index):
+               if index == 'end':
+                       self.NextStep = 'end'
+               else:
+                       self.NextStep = 'removeextensions'
+
+       def ActionSelectionMoved(self):
+               self.ActionSelect(self.selection)
+
+       def buildList(self,action):
+               if self.NextStep is not 'end':
+                       if not self.Console:
+                               self.Console = Console()
+                       cmd = "ipkg list_installed | grep enigma2"
+                       self.Console.ePopen(cmd, self.buildListInstalled_Finished)
+                       self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _("Please wait while searching for removable packages..."), type = MessageBox.TYPE_INFO, enable_input = False)
+               else:
+                       self.buildListfinishedCB(False)
+
+       def buildListInstalled_Finished(self, result, retval, extra_args = None):
+               if len(result):
+                       self.installed_packetlist = []
+                       for x in result.splitlines():
+                               split = x.split(' - ')
+                               if not any(split[0].strip().endswith(x) for x in self.excluded_extensions): #ignore some base plugins
+                                       if split[0].strip() != 'enigma2':
+                                               self.installed_packetlist.append((split[0].strip()))
+               self.buildListRef.close(True)
+
+       def buildListfinishedCB(self,data):
+               self.buildListRef = None
+               if data is True:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+               else:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+
+       def listInstalledPackages(self):
+               list = []
+               if self.installed_packetlist and len(self.installed_packetlist):
+                       for x in self.installed_packetlist:
+                               if x.startswith('enigma2-plugin-'):
+                                       pluginname = x.replace("enigma2-plugin-","")
+                               elif x.startswith('enigma2-skin-'):
+                                       pluginname = x.replace("enigma2-","")
+                               else:
+                                       pluginname = x
+                               list.append( (pluginname,x) )
+               return list
+
+       def PackageSelectionMade(self, index):
+               self.PackageSelect(index)
+
+       def PackageSelectionMoved(self):
+               self.PackageSelect(self.selection)
+
+       def PackageSelect(self, package):
+               self.selectedPackage = package
+
+       def ipkgCallback(self, event, param):
+               if event == IpkgComponent.EVENT_ERROR:
+                       freeSpace = checkFreeSpaceAvailable()
+                       txt_line1 = _("There was an error. The package:") + "\n" + str(self.selectedPackage) + "\n" + _("could not be removed") + "\n"
+                       txt_line2 = _("There are now ") + str(freeSpace) + " kB " + _("available") + "\n\n"
+                       txt_line3 = _("Please select an option below.")
+                       self.Text = txt_line1 + txt_line2 + txt_line3
+                       self.NextStep = 'StatusRemoveERROR'
+                       self.RemoveRef.close(True)
+               elif event == IpkgComponent.EVENT_DONE:
+                       freeSpace = checkFreeSpaceAvailable()
+                       txt_line1 = _("The package:") + "\n" + str(self.selectedPackage) + "\n" + _("was removed successfully") + "\n"
+                       txt_line2 = _("There are now ") + str(freeSpace) + " kB " + _("available") + "\n\n"
+                       txt_line3 = _("Please select an option below.")
+                       self.Text = txt_line1 + txt_line2 + txt_line3
+                       self.NextStep = 'StatusRemoveOK'
+                       self.RemoveRef.close(True)
+               pass
+
+       def removeExtension(self,extension):
+               if self.NextStep is not 'end':
+                       self.ipkg.startCmd(IpkgComponent.CMD_REMOVE, {'package': extension})
+                       self.RemoveRef = self.session.openWithCallback(self.removeExtensionFinishedCB, MessageBox, _("Please wait while removing selected package..."), type = MessageBox.TYPE_INFO, enable_input = False)
+               else:
+                       self.buildListfinishedCB(False)
+
+       def removeExtensionFinishedCB(self,data):
+               self.RemoveRef = None
+               if data is True:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+               else:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/LICENSE b/lib/python/Plugins/SystemPlugins/CleanupWizard/LICENSE
new file mode 100755 (executable)
index 0000000..f8473e0
--- /dev/null
@@ -0,0 +1,12 @@
+This plugin is licensed under the Creative Commons
+Attribution-NonCommercial-ShareAlike 3.0 Unported
+License. To view a copy of this license, visit
+http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
+Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
+
+Alternatively, this plugin may be distributed and executed on hardware which
+is licensed by Dream Multimedia GmbH.
+
+This plugin is NOT free software. It is open source, you are allowed to
+modify it (if you keep the license), but it may not be commercially
+distributed other than under the conditions noted above.
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile.am b/lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile.am
new file mode 100755 (executable)
index 0000000..72f842c
--- /dev/null
@@ -0,0 +1,12 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/CleanupWizard
+
+SUBDIRS = meta
+
+install_PYTHON =       \
+       __init__.py \
+       plugin.py \
+       CleanupWizard.py
+
+dist_install_DATA = \
+       LICENSE \
+       cleanupwizard.xml
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/__init__.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml b/lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml
new file mode 100755 (executable)
index 0000000..1404ca5
--- /dev/null
@@ -0,0 +1,59 @@
+<wizard>
+       <step id="welcome">
+               <text value="Welcome to the cleanup wizard.\n\nWe have detected that your available internal memory has dropped below 2MB.\n\nTo ensure stable operation of your Dreambox, the internal memory should be cleaned up.\nYou can use this wizard to remove some extensions." />
+               <displaytext value="Cleanup Wizard" />
+               <list type="dynamic" source="listAction" evaluation="ActionSelectionMade" onselect="ActionSelectionMoved" />
+               <code>
+self.clearSelectedKeys()
+self.selectKey("OK")
+               </code>
+               <code pos="after" async="yes">
+self.buildList(self.selectedAction)
+               </code>
+       </step>
+
+       <step id="removeextensions">
+               <text value="Please select an extension to remove." />
+               <displaytext value="Select package" />
+               <list type="dynamic" source="listInstalledPackages" evaluation="PackageSelectionMade" onselect="PackageSelectionMoved" />
+               <code>
+self.clearSelectedKeys()
+self.selectKey("OK")
+self.selectKey("UP")
+self.selectKey("DOWN")
+               </code>
+               <code pos="after" async="yes">
+self.removeExtension(self.selectedPackage)
+               </code>
+       </step>
+
+       <step id="StatusRemoveOK">
+               <text value="Package removed successfully.\n" />
+               <displaytext value="Removed successfully." />
+               <list type="dynamic" source="listAgainAction" evaluation="ActionSelectionMade" onselect="ActionSelectionMoved" />
+               <code>
+self["text"].setText(self.Text)
+self.clearSelectedKeys()
+self.selectKey("OK")
+               </code>
+               <code pos="after" async="yes">
+self.buildList(self.selectedAction)
+               </code>
+       </step>
+       <step id="StatusRemoveERROR">
+               <text value="Package removal failed.\n" />
+               <displaytext value="Remove failed." />
+               <list type="dynamic" source="listAgainAction" evaluation="ActionSelectionMade" onselect="ActionSelectionMoved" />
+               <code>
+self["text"].setText(self.Text)
+self.clearSelectedKeys()
+self.selectKey("OK")
+               </code>
+               <code pos="after" async="yes">
+self.buildList(self.selectedAction)
+               </code>
+       </step>
+       <step id="end">
+               <text value="The wizard is finished now." />
+       </step>
+</wizard>
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..125ce5c
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(pkgdatadir)/meta/enigma2/
+
+dist_install_DATA = plugin_cleanupwizard.xml
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml
new file mode 100755 (executable)
index 0000000..261eb49
--- /dev/null
@@ -0,0 +1,26 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info language="en">
+                    <author>Dream Multimedia</author>
+                    <name>CrashlogAutoSubmit</name>
+                    <packagename>enigma2-plugin-systemplugins-crashlogautosubmit</packagename>
+                    <shortdescription>Automatically send crashlogs to Dream Multimedia</shortdescription>
+                    <description>With the CrashlogAutoSubmit extension it is possible to automatically send crashlogs
+                   found on your Harddrive to Dream Multimedia
+                    </description>
+          </info>
+          <info language="de">
+                    <author>Dream Multimedia</author>
+                    <name>CrashlogAutoSubmit</name>
+                    <packagename>enigma2-plugin-systemplugins-crashlogautosubmit</packagename>
+                    <shortdescription>Automatisches versenden von Crashlogs an Dream Multimedia</shortdescription>
+                    <description>Mit dem CrashlogAutoSubmit Plugin ist es möglich auf Ihrer Festplatte
+                   gefundene Crashlogs automatisch  an Dream Multimedia zu versenden.
+                    </description>
+          </info>
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-crashlogautosubmit" />
+         </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py
new file mode 100755 (executable)
index 0000000..c1af50d
--- /dev/null
@@ -0,0 +1,29 @@
+from Screens.Screen import Screen
+from Plugins.Plugin import PluginDescriptor
+from Components.PluginComponent import plugins
+from Components.config import config
+from CleanupWizard import checkFreeSpaceAvailable
+
+freeSpace = checkFreeSpaceAvailable()
+print "[CleanupWizard] freeSpaceAvailable-->",freeSpace
+
+
+if freeSpace is None:
+       internalMemoryExceeded = 0
+elif int(freeSpace) <= 12048:
+       internalMemoryExceeded = 1
+else:
+       internalMemoryExceeded = 0
+
+
+def CleanupWizard(*args, **kwargs):
+       from CleanupWizard import CleanupWizard
+       return CleanupWizard(*args, **kwargs)
+
+def Plugins(**kwargs):
+       list = []
+       if not config.misc.firstrun.value:
+               if internalMemoryExceeded:
+                       list.append(PluginDescriptor(name=_("Cleanup Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=(1, CleanupWizard)))
+       return list
+
old mode 100644 (file)
new mode 100755 (executable)
index 8d25644..33845f1
@@ -1,4 +1,4 @@
 SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
 SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
-       CrashlogAutoSubmit
+       CrashlogAutoSubmit CleanupWizard
index b589e70..f6d4fd5 100755 (executable)
@@ -31,6 +31,7 @@ enigma2.pot:
        ./xml2po.py     ../data/ >> enigma2.pot
        ./xml2po.py     ../lib/python/Plugins/SystemPlugins/Videomode/ >> enigma2.pot
        ./xml2po.py     ../lib/python/Plugins/SystemPlugins/SoftwareManager/ >> enigma2.pot
        ./xml2po.py     ../data/ >> enigma2.pot
        ./xml2po.py     ../lib/python/Plugins/SystemPlugins/Videomode/ >> enigma2.pot
        ./xml2po.py     ../lib/python/Plugins/SystemPlugins/SoftwareManager/ >> enigma2.pot
+       ./xml2po.py     ../lib/python/Plugins/SystemPlugins/CleanupWizard/ >> enigma2.pot
        cat enigma2_rel25.pot | tail -n +19 >> enigma2.pot
        msguniq -o enigma2uniq.pot enigma2.pot
        $(RM) enigma2.pot
        cat enigma2_rel25.pot | tail -n +19 >> enigma2.pot
        msguniq -o enigma2uniq.pot enigma2.pot
        $(RM) enigma2.pot