dont crash when not official-feed.conf found
authorghost <andreas.monzner@multimedia-labs.de>
Sat, 14 Feb 2009 11:01:42 +0000 (12:01 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Sat, 14 Feb 2009 11:01:42 +0000 (12:01 +0100)
lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py

index 81e1e9f9c7da2ac7cdcecd9b983dc178a36837fa..a8654895d4cbdfb318a4e15f791b2696753ac1f0 100755 (executable)
@@ -231,13 +231,20 @@ class IPKGSource(Screen):
        def __init__(self, session, args = None):
                Screen.__init__(self, session)
                self.session = session
        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,
                self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions"], 
                {
                        "ok": self.go,
@@ -261,9 +268,11 @@ class IPKGSource(Screen):
                }, -1)
                
        def go(self):
                }, -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):
                self.close()
                
        def keyLeft(self):
@@ -288,7 +297,6 @@ class IPKGSource(Screen):
                print "pressed", number
                self["text"].number(number)
 
                print "pressed", number
                self["text"].number(number)
 
-
 class PacketList(MenuList):
        def __init__(self, list, enableWrapAround=True):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
 class PacketList(MenuList):
        def __init__(self, list, enableWrapAround=True):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)