dont crash when not official-feed.conf found
[enigma2.git] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
index 85d23284d453f7e99d271b1268c786909137684c..a8654895d4cbdfb318a4e15f791b2696753ac1f0 100755 (executable)
@@ -231,13 +231,20 @@ class IPKGSource(Screen):
        def __init__(self, session, args = None):
                Screen.__init__(self, session)
                self.session = session
-               
-               fp = file('/etc/ipkg/official-feed.conf', 'r')
-               sources = fp.readlines()
-               fp.close()
-               
-               self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT)
-                               
+
+               #FIXMEEEE add handling for more than one feed conf file!
+               text = ""
+               try:
+                       fp = file('/etc/ipkg/official-feed.conf', 'r')
+                       sources = fp.readlines()
+                       if sources:
+                               text = sources[0]
+                       fp.close()
+               except IOError:
+                       pass
+
+               self["text"] = Input(text, maxSize=False, type=Input.TEXT)
+
                self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions"], 
                {
                        "ok": self.go,
@@ -261,9 +268,11 @@ class IPKGSource(Screen):
                }, -1)
                
        def go(self):
-               fp = file('/etc/ipkg/official-feed.conf', 'w')
-               fp.write(self["text"].getText())
-               fp.close()
+               text = self["text"].getText()
+               if text:
+                       fp = file('/etc/ipkg/official-feed.conf', 'w')
+                       fp.write()
+                       fp.close()
                self.close()
                
        def keyLeft(self):
@@ -288,7 +297,6 @@ class IPKGSource(Screen):
                print "pressed", number
                self["text"].number(number)
 
-
 class PacketList(MenuList):
        def __init__(self, list, enableWrapAround=True):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
@@ -342,7 +350,7 @@ class PacketManager(Screen):
                self.onShown.append(self.setWindowTitle)
                self.onLayoutFinish.append(self.rebuildList)
                self.onClose.append(self.cleanup)
-               
+
        def cleanup(self):
                self.ipkg.stop()
                if self.Console is not None:
@@ -448,6 +456,8 @@ class PacketManager(Screen):
                        for x in result.splitlines():
                                split = x.split(' - ')
                                self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()])
+               if not self.Console:
+                       self.Console = Console()
                cmd = "ipkg list_installed"
                self.Console.ePopen(cmd, self.IpkgListInstalled_Finished)