From 1b69c6d4604804d03cc4ac3cccaa16b7ae70ccad Mon Sep 17 00:00:00 2001 From: acid-burn Date: Thu, 27 Aug 2009 17:38:58 +0200 Subject: [PATCH] Enigma2: add CleanupWizard to SystemPlugins and Enigma2 build. - 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 | 2 + .../CleanupWizard/CleanupWizard.py | 172 ++++++++++++++++++ .../SystemPlugins/CleanupWizard/LICENSE | 12 ++ .../SystemPlugins/CleanupWizard/Makefile.am | 12 ++ .../SystemPlugins/CleanupWizard/__init__.py | 0 .../CleanupWizard/cleanupwizard.xml | 59 ++++++ .../CleanupWizard/meta/Makefile.am | 3 + .../meta/plugin_cleanupwizard.xml | 26 +++ .../SystemPlugins/CleanupWizard/plugin.py | 29 +++ lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- po/Makefile.am | 1 + 11 files changed, 317 insertions(+), 1 deletion(-) create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/LICENSE create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/__init__.py create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml create mode 100755 lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/Makefile.am diff --git a/configure.ac b/configure.ac index 1a2d1e06..fea6a0dc 100755 --- a/configure.ac +++ b/configure.ac @@ -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/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 diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py new file mode 100755 index 00000000..d8de3544 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/CleanupWizard.py @@ -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 = """ + + + + + + + + + + + + + + + """ + + 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 index 00000000..f8473e02 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/LICENSE @@ -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 index 00000000..72f842c2 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile.am @@ -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 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml b/lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml new file mode 100755 index 00000000..1404ca5f --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/cleanupwizard.xml @@ -0,0 +1,59 @@ + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + +self.buildList(self.selectedAction) + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + + +self.removeExtension(self.selectedPackage) + + + + + + + + +self["text"].setText(self.Text) +self.clearSelectedKeys() +self.selectKey("OK") + + +self.buildList(self.selectedAction) + + + + + + + +self["text"].setText(self.Text) +self.clearSelectedKeys() +self.selectKey("OK") + + +self.buildList(self.selectedAction) + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am new file mode 100755 index 00000000..125ce5cd --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile.am @@ -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 index 00000000..261eb497 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml @@ -0,0 +1,26 @@ + + + + + + Dream Multimedia + CrashlogAutoSubmit + enigma2-plugin-systemplugins-crashlogautosubmit + Automatically send crashlogs to Dream Multimedia + With the CrashlogAutoSubmit extension it is possible to automatically send crashlogs + found on your Harddrive to Dream Multimedia + + + + Dream Multimedia + CrashlogAutoSubmit + enigma2-plugin-systemplugins-crashlogautosubmit + Automatisches versenden von Crashlogs an Dream Multimedia + Mit dem CrashlogAutoSubmit Plugin ist es möglich auf Ihrer Festplatte + gefundene Crashlogs automatisch an Dream Multimedia zu versenden. + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py b/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py new file mode 100755 index 00000000..c1af50d2 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/plugin.py @@ -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 + diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am old mode 100644 new mode 100755 index 8d256445..33845f17 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -1,4 +1,4 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \ DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \ - CrashlogAutoSubmit + CrashlogAutoSubmit CleanupWizard diff --git a/po/Makefile.am b/po/Makefile.am index b589e70a..f6d4fd5c 100755 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -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 ../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 -- 2.30.2