wizard: remove default files, channels and stb presets
[openblackhole/openblackhole-enigma2.git] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
index 1265992..0869cee 100644 (file)
@@ -3,7 +3,7 @@ from Screens.Console import Console
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
 from Screens.Screen import Screen
-from Screens.Standby import TryQuitMainloop 
+from Screens.Standby import TryQuitMainloop
 from Screens.Ipkg import Ipkg
 from Screens.SoftwareUpdate import UpdatePlugin
 from Components.ActionMap import ActionMap, NumberActionMap
@@ -23,7 +23,6 @@ from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixm
 from Components.SelectionList import SelectionList
 from Components.PluginComponent import plugins
 from Components.About import about
-from Components.DreamInfoHandler import DreamInfoHandler
 from Components.Language import language
 from Components.AVSwitch import AVSwitch
 from Components.Task import job_manager
@@ -51,7 +50,7 @@ config.plugins.softwaremanager = ConfigSubsection()
 config.plugins.softwaremanager.overwriteConfigFiles = ConfigSelection(
                                [
                                 ("Y", _("Yes, always")),
-                                ("N", _("No, never")),                          
+                                ("N", _("No, never")),
                                 ("ask", _("Always ask"))
                                ], "Y")
 config.plugins.softwaremanager.onSetupMenu = ConfigYesNo(default=False)
@@ -116,7 +115,7 @@ class UpdatePluginMenu(Screen):
                        </widget>
                        <widget source="status" render="Label" position="5,360" zPosition="10" size="600,50" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
                </screen>"""
-               
+
        def __init__(self, session, args = 0):
                Screen.__init__(self, session)
                self.skin_path = plugin_path
@@ -239,7 +238,7 @@ class UpdatePluginMenu(Screen):
 
        def handleMenu(self):
                self.session.open(SoftwareManagerSetup)
-               
+
        def handleInfo(self):
                current = self["menu"].getCurrent()
                if current:
@@ -306,7 +305,7 @@ class UpdatePluginMenu(Screen):
                config.plugins.configurationbackup.backupdirs.save()
                config.plugins.configurationbackup.save()
                config.save()
-               
+
        def backuplocation_choosen(self, option):
                oldpath = config.plugins.configurationbackup.backuplocation.getValue()
                if option is not None:
@@ -391,7 +390,7 @@ class SoftwareManagerSetup(Screen, ConfigListScreen):
        def createSetup(self):
                self.list = [ ]
                self.overwriteConfigfilesEntry = getConfigListEntry(_("Overwrite configuration files ?"), config.plugins.softwaremanager.overwriteConfigFiles)
-               self.list.append(self.overwriteConfigfilesEntry)        
+               self.list.append(self.overwriteConfigfilesEntry)
                self.list.append(getConfigListEntry(_("show softwaremanager in setup menu"), config.plugins.softwaremanager.onSetupMenu))
                self.list.append(getConfigListEntry(_("show softwaremanager on blue button"), config.plugins.softwaremanager.onBlueButton))
 
@@ -500,7 +499,7 @@ class SoftwareManagerInfo(Screen):
 
                self.list = []
                self["list"] = List(self.list)
-               
+
                self["key_red"] = StaticText(_("Close"))
                self["key_green"] = StaticText()
                self["key_yellow"] = StaticText()
@@ -521,9 +520,9 @@ class SoftwareManagerInfo(Screen):
                        for entry in backupfiles:
                                self.list.append((entry,))
                        self['list'].setList(self.list)
-                       
 
-class PluginManager(Screen, DreamInfoHandler):
+
+class PluginManager(Screen):
 
        skin = """
                <screen name="PluginManager" position="center,center" size="560,440" title="Extensions management" >
@@ -599,7 +598,7 @@ class PluginManager(Screen, DreamInfoHandler):
                self.currentSelectedPackage = None
                self.saved_currentSelectedPackage = None
                self.restartRequired = False
-               
+
                self.onShown.append(self.setWindowTitle)
                self.onLayoutFinish.append(self.getUpdateInfos)
 
@@ -675,7 +674,7 @@ class PluginManager(Screen, DreamInfoHandler):
                                        iSoftwareTools.lastDownloadDate = time()
                                        iSoftwareTools.list_updating = True
                                        self.setState('update')
-                                       iSoftwareTools.getUpdates(self.getUpdateInfosCB)                                        
+                                       iSoftwareTools.getUpdates(self.getUpdateInfosCB)
 
        def rebuildList(self, retval = None):
                if self.currentSelectedTag is None:
@@ -774,7 +773,7 @@ class PluginManager(Screen, DreamInfoHandler):
                                iSoftwareTools.list_updating = True
                                self.setState('update')
                                iSoftwareTools.getUpdates(self.getUpdateInfosCB)
-                               
+
        def handleSelected(self):
                current = self["list"].getCurrent()
                if current:
@@ -1151,7 +1150,7 @@ class PluginManagerHelp(Screen):
                self.close()
 
 
-class PluginDetails(Screen, DreamInfoHandler):
+class PluginDetails(Screen):
        skin = """
                <screen name="PluginDetails" position="center,center" size="600,440" title="Plugin details" >
                        <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
@@ -1169,7 +1168,6 @@ class PluginDetails(Screen, DreamInfoHandler):
                self.skin_path = plugin_path
                self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
                self.attributes = None
-               DreamInfoHandler.__init__(self, self.statusCallback, blocking = False)
                self.directory = resolveFilename(SCOPE_METADIR)
                if packagedata:
                        self.pluginname = packagedata[0]
@@ -1227,9 +1225,6 @@ class PluginDetails(Screen, DreamInfoHandler):
        def pageDown(self):
                self["detailtext"].pageDown()
 
-       def statusCallback(self, status, progress):
-               pass
-
        def setInfos(self):
                if self.attributes.has_key("screenshot"):
                        self.loadThumbnail(self.attributes)
@@ -1364,7 +1359,7 @@ class IPKGMenu(Screen):
        def __init__(self, session, plugin_path):
                Screen.__init__(self, session)
                self.skin_path = plugin_path
-               
+
                self["key_red"] = StaticText(_("Close"))
                self["key_green"] = StaticText(_("Edit"))
 
@@ -1372,7 +1367,7 @@ class IPKGMenu(Screen):
                self.val = []
                self.entry = False
                self.exe = False
-               
+
                self.path = ""
 
                self["actions"] = NumberActionMap(["SetupActions"],
@@ -1459,7 +1454,7 @@ class IPKGSource(Screen):
                else:
                        self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT)
 
-               self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"], 
+               self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"],
                {
                        "ok": self.go,
                        "back": self.close,
@@ -1503,22 +1498,22 @@ class IPKGSource(Screen):
 
        def keyLeft(self):
                self["text"].left()
-       
+
        def keyRight(self):
                self["text"].right()
-       
+
        def keyHome(self):
                self["text"].home()
-       
+
        def keyEnd(self):
                self["text"].end()
-       
+
        def keyDeleteForward(self):
                self["text"].delete()
-       
+
        def keyDeleteBackward(self):
                self["text"].deleteBackward()
-       
+
        def keyNumberGlobal(self, number):
                self["text"].number(number)
 
@@ -1544,7 +1539,7 @@ class PacketManager(Screen, NumericalTextInput):
                                </convert>
                        </widget>
                </screen>"""
-               
+
        def __init__(self, session, plugin_path, args = None):
                Screen.__init__(self, session)
                NumericalTextInput.__init__(self)
@@ -1571,7 +1566,7 @@ class PacketManager(Screen, NumericalTextInput):
                        "9": self.keyNumberGlobal,
                        "0": self.keyNumberGlobal
                }, -1)
-               
+
                self.list = []
                self.statuslist = []
                self["list"] = List(self.list)
@@ -1596,7 +1591,7 @@ class PacketManager(Screen, NumericalTextInput):
                self.onLayoutFinish.append(self.rebuildList)
 
                rcinput = eRCInput.getInstance()
-               rcinput.setKeyboardMode(rcinput.kmAscii)                
+               rcinput.setKeyboardMode(rcinput.kmAscii)
 
        def keyNumberGlobal(self, val):
                key = self.getKey(val)
@@ -1604,12 +1599,12 @@ class PacketManager(Screen, NumericalTextInput):
                        keyvalue = key.encode("utf-8")
                        if len(keyvalue) == 1:
                                self.setNextIdx(keyvalue[0])
-               
+
        def keyGotAscii(self):
                keyvalue = unichr(getPrevAsciiCode()).encode("utf-8")
                if len(keyvalue) == 1:
                        self.setNextIdx(keyvalue[0])
-               
+
        def setNextIdx(self,char):
                if char in ("0", "1", "a"):
                        self["list"].setIndex(0)
@@ -1638,7 +1633,7 @@ class PacketManager(Screen, NumericalTextInput):
                        remove(self.cache_file)
                        self.list_updating = True
                        self.rebuildList()
-                       
+
        def setWindowTitle(self):
                self.setTitle(_("Packet manager"))
 
@@ -1649,11 +1644,11 @@ class PacketManager(Screen, NumericalTextInput):
                        if status == 'update':
                                statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png"))
                                self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'',statuspng, divpng ))
-                               self['list'].setList(self.statuslist)   
+                               self['list'].setList(self.statuslist)
                        elif status == 'error':
                                statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png"))
                                self.statuslist.append(( _("Error"), '', _("There was an error downloading the packetlist. Please try again." ),'',statuspng, divpng ))
-                               self['list'].setList(self.statuslist)                           
+                               self['list'].setList(self.statuslist)
 
        def rebuildList(self):
                self.setStatus('update')
@@ -1715,7 +1710,7 @@ class PacketManager(Screen, NumericalTextInput):
 
        def runUpgradeFinished(self):
                self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your receiver?"), MessageBox.TYPE_YESNO)
-               
+
        def UpgradeReboot(self, result):
                if result is None:
                        return
@@ -1742,7 +1737,6 @@ class PacketManager(Screen, NumericalTextInput):
                                        self.Console = Console()
                                cmd = self.ipkg.ipkg + " list"
                                self.Console.ePopen(cmd, self.IpkgList_Finished)
-               #print event, "-", param
                pass
 
        def IpkgList_Finished(self, result, retval, extra_args = None):
@@ -1750,7 +1744,7 @@ class PacketManager(Screen, NumericalTextInput):
                        self.packetlist = []
                        last_name = ""
                        for x in result.splitlines():
-                               tokens = x.split(' - ') 
+                               tokens = x.split(' - ')
                                name = tokens[0].strip()
                                if not any(name.endswith(x) for x in self.unwanted_extensions):
                                        l = len(tokens)
@@ -1758,7 +1752,7 @@ class PacketManager(Screen, NumericalTextInput):
                                        descr = l > 2 and tokens[2].strip() or ""
                                        if name == last_name:
                                                continue
-                                       last_name = name 
+                                       last_name = name
                                        self.packetlist.append([name, version, descr])
 
                if not self.Console:
@@ -1792,17 +1786,17 @@ class PacketManager(Screen, NumericalTextInput):
                                        version = l > 2 and tokens[2].strip() or ""
                                        self.upgradeable_packages[name] = version
                self.buildPacketList()
-       
+
        def buildEntryComponent(self, name, version, description, state):
                divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
                if not description:
                        description = "No description available."
                if state == 'installed':
                        installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png"))
-                       return((name, version, _(description), state, installedpng, divpng))    
+                       return((name, version, _(description), state, installedpng, divpng))
                elif state == 'upgradeable':
                        upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgradeable.png"))
-                       return((name, version, _(description), state, upgradeablepng, divpng))  
+                       return((name, version, _(description), state, upgradeablepng, divpng))
                else:
                        installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png"))
                        return((name, version, _(description), state, installablepng, divpng))
@@ -1832,7 +1826,7 @@ class PacketManager(Screen, NumericalTextInput):
                                                status = "installed"
                                else:
                                        status = "installable"
-                               self.list.append(self.buildEntryComponent(x[0], x[1], x[2], status))    
+                               self.list.append(self.buildEntryComponent(x[0], x[1], x[2], status))
                                self.cachelist.append([x[0], x[1], x[2], status])
                        write_cache(self.cache_file, self.cachelist)
                        self['list'].setList(self.list)
@@ -1856,7 +1850,7 @@ class IpkgInstaller(Screen):
                        <ePixmap pixmap="skin_default/div-h.png" position="0,410" zPosition="10" size="560,2" transparent="1" alphatest="on" />
                        <widget source="introduction" render="Label" position="5,420" zPosition="10" size="550,30" halign="center" valign="center" font="Regular;22" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
                </screen>"""
-       
+
        def __init__(self, session, list):
                Screen.__init__(self, session)
 
@@ -1870,8 +1864,8 @@ class IpkgInstaller(Screen):
                self["key_yellow"] = StaticText()
                self["key_blue"] = StaticText(_("Invert"))
                self["introduction"] = StaticText(_("Press OK to toggle the selection."))
-               
-               self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], 
+
+               self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
                {
                        "ok": self.list.toggleSelection,
                        "cancel": self.close,
@@ -1895,13 +1889,13 @@ def filescan_open(list, session, **kwargs):
 def filescan(**kwargs):
        from Components.Scanner import Scanner, ScanPath
        return \
-               Scanner(mimetypes = ["application/x-debian-package"], 
-                       paths_to_scan = 
+               Scanner(mimetypes = ["application/x-debian-package"],
+                       paths_to_scan =
                                [
-                                       ScanPath(path = "ipk", with_subdirs = True), 
-                                       ScanPath(path = "", with_subdirs = False), 
-                               ], 
-                       name = "Ipkg", 
+                                       ScanPath(path = "ipk", with_subdirs = True),
+                                       ScanPath(path = "", with_subdirs = False),
+                               ],
+                       name = "Ipkg",
                        description = _("Install extensions."),
                        openfnc = filescan_open, )
 
@@ -1909,7 +1903,7 @@ def UpgradeMain(session, **kwargs):
        session.open(UpdatePluginMenu)
 
 def startSetup(menuid):
-       if menuid == "setup" and config.plugins.softwaremanager.onSetupMenu.value: 
+       if menuid == "setup" and config.plugins.softwaremanager.onSetupMenu.value:
                return [(_("Software management"), UpgradeMain, "software_manager", 50)]
        return [ ]