lib/python/Plugins/SystemPlugins/SoftwareManager: more robust code this i.e. fixes:
authorghost <andreas.monzner@multimedia-labs.de>
Tue, 9 Feb 2010 18:45:42 +0000 (19:45 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Tue, 9 Feb 2010 18:45:42 +0000 (19:45 +0100)
Traceback (most recent call last):
  File "/usr/lib/enigma2/python/Tools/BoundFunction.py", line 9, in __call__
     return self.fnc(*self.args + args, **newkwargs)
   File "/usr/lib/enigma2/python/Components/Console.py", line 56, in finishedCB
     self.callbacks[name](data,retval,extra_args)
   File "/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py", line 108, in IpkgListAvailableCB
     SoftwareTools.available_packetlist.append([name, split[1].strip(), split[2].strip()])

ref bug #383

lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py
lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py

index 4e7591e..e8cf6dc 100755 (executable)
@@ -94,14 +94,17 @@ class SoftwareTools(DreamInfoHandler):
 
        def IpkgListAvailableCB(self, result, retval, extra_args = None):
                (callback) = extra_args
 
        def IpkgListAvailableCB(self, result, retval, extra_args = None):
                (callback) = extra_args
-               if len(result):
+               if result:
                        if SoftwareTools.list_updating:
                                SoftwareTools.available_packetlist = []
                                for x in result.splitlines():
                        if SoftwareTools.list_updating:
                                SoftwareTools.available_packetlist = []
                                for x in result.splitlines():
-                                       split = x.split(' - ')
-                                       name = split[0].strip()
+                                       tokens = x.split(' - ')
+                                       name = tokens[0].strip()
                                        if not any(name.endswith(x) for x in self.unwanted_extensions):
                                        if not any(name.endswith(x) for x in self.unwanted_extensions):
-                                               SoftwareTools.available_packetlist.append([name, split[1].strip(), split[2].strip()])
+                                               l = len(tokens)
+                                               version = l > 1 and tokens[1].strip() or ""
+                                               descr = l > 2 and tokens[2].strip() or ""
+                                               SoftwareTools.available_packetlist.append([name, version, descr])
                                if callback is None:
                                        self.startInstallMetaPackage()
                                else:
                                if callback is None:
                                        self.startInstallMetaPackage()
                                else:
@@ -126,7 +129,7 @@ class SoftwareTools(DreamInfoHandler):
 
        def InstallMetaPackageCB(self, result, retval, extra_args = None):
                (callback) = extra_args
 
        def InstallMetaPackageCB(self, result, retval, extra_args = None):
                (callback) = extra_args
-               if len(result):
+               if result:
                        self.fillPackagesIndexList()
                        if callback is None:
                                self.startIpkgListInstalled()
                        self.fillPackagesIndexList()
                        if callback is None:
                                self.startIpkgListInstalled()
@@ -152,13 +155,15 @@ class SoftwareTools(DreamInfoHandler):
 
        def IpkgListInstalledCB(self, result, retval, extra_args = None):
                (callback) = extra_args
 
        def IpkgListInstalledCB(self, result, retval, extra_args = None):
                (callback) = extra_args
-               if len(result):
+               if result:
                        SoftwareTools.installed_packetlist = {}
                        for x in result.splitlines():
                        SoftwareTools.installed_packetlist = {}
                        for x in result.splitlines():
-                               split = x.split(' - ')
-                               name = split[0].strip()
+                               tokens = x.split(' - ')
+                               name = tokens[0].strip()
                                if not any(name.endswith(x) for x in self.unwanted_extensions):
                                if not any(name.endswith(x) for x in self.unwanted_extensions):
-                                       SoftwareTools.installed_packetlist[name] = split[1].strip()
+                                       l = len(tokens)
+                                       version = l > 1 and tokens[1].strip() or ""
+                                       SoftwareTools.installed_packetlist[name] = version
                        if callback is None:
                                self.countUpdates()
                        else:
                        if callback is None:
                                self.countUpdates()
                        else:
@@ -203,7 +208,7 @@ class SoftwareTools(DreamInfoHandler):
 
        def IpkgUpdateCB(self, result, retval, extra_args = None):
                (callback) = extra_args
 
        def IpkgUpdateCB(self, result, retval, extra_args = None):
                (callback) = extra_args
-               if len(result):
+               if result:
                        if self.Console:
                                if len(self.Console.appContainers) == 0:
                                        if callback is not None:
                        if self.Console:
                                if len(self.Console.appContainers) == 0:
                                        if callback is not None:
index b20ba51..4dbe7f7 100755 (executable)
@@ -1558,24 +1558,31 @@ class PacketManager(Screen):
                pass
 
        def IpkgList_Finished(self, result, retval, extra_args = None):
                pass
 
        def IpkgList_Finished(self, result, retval, extra_args = None):
-               if len(result):
+               if result:
                        self.packetlist = []
                        for x in result.splitlines():
                        self.packetlist = []
                        for x in result.splitlines():
-                               split = x.split(' - ')   #self.blacklisted_packages
-                               if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions):
-                                       self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()])
+                               tokens = x.split(' - ')   #self.blacklisted_packages
+                               name = tokens[0].strip()
+                               if not any(name.endswith(x) for x in self.unwanted_extensions):
+                                       l = len(tokens)
+                                       version = l > 1 and tokens[1].strip() or ""
+                                       descr = l > 2 and tokens[2].strip() or ""
+                                       self.packetlist.append([name, version, descr])
                if not self.Console:
                        self.Console = Console()
                cmd = "ipkg list_installed"
                self.Console.ePopen(cmd, self.IpkgListInstalled_Finished)
 
        def IpkgListInstalled_Finished(self, result, retval, extra_args = None):
                if not self.Console:
                        self.Console = Console()
                cmd = "ipkg list_installed"
                self.Console.ePopen(cmd, self.IpkgListInstalled_Finished)
 
        def IpkgListInstalled_Finished(self, result, retval, extra_args = None):
-               if len(result):
+               if result:
                        self.installed_packetlist = {}
                        for x in result.splitlines():
                        self.installed_packetlist = {}
                        for x in result.splitlines():
-                               split = x.split(' - ')
-                               if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions):
-                                       self.installed_packetlist[split[0].strip()] = split[1].strip()
+                               tokens = x.split(' - ')   #self.blacklisted_packages
+                               name = tokens[0].strip()
+                               if not any(name.endswith(x) for x in self.unwanted_extensions):
+                                       l = len(tokens)
+                                       version = l > 1 and tokens[1].strip() or ""
+                                       self.installed_packetlist[name] = version
                self.buildPacketList()
 
        def buildEntryComponent(self, name, version, description, state):
                self.buildPacketList()
 
        def buildEntryComponent(self, name, version, description, state):
@@ -1703,7 +1710,7 @@ def Plugins(path, **kwargs):
        plugin_path = path
        list = [
                PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart),
        plugin_path = path
        list = [
                PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart),
-               PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), 
+               PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup),
                PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)
        ]
        if config.usage.setup_level.index >= 2: # expert+
                PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)
        ]
        if config.usage.setup_level.index >= 2: # expert+