fix some crashes during settings wizard
authorAndreas Oberritter <obi@opendreambox.org>
Fri, 25 Mar 2011 18:58:57 +0000 (19:58 +0100)
committerAndreas Oberritter <obi@opendreambox.org>
Tue, 29 Mar 2011 13:43:58 +0000 (15:43 +0200)
lib/python/Components/config.py
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
lib/python/Screens/DefaultWizard.py
lib/python/Tools/Directories.py

index 6e5608570b7d7b7410c7d010414fdfb822930301..5507cae9493b23fcc5217416bda5a3404b85d186 100755 (executable)
@@ -1661,9 +1661,12 @@ class Config(ConfigSubsection):
 
        def saveToFile(self, filename):
                text = self.pickle()
 
        def saveToFile(self, filename):
                text = self.pickle()
-               f = open(filename, "w")
-               f.write(text)
-               f.close()
+               try:
+                       f = open(filename, "w")
+                       f.write(text)
+                       f.close()
+               except IOError:
+                       print "Config: Couldn't write %s" % filename
 
        def loadFromFile(self, filename, base_file=False):
                f = open(filename, "r")
 
        def loadFromFile(self, filename, base_file=False):
                f = open(filename, "r")
index dc4e8c564ac67f2ccc1dc980f0f231447f3f4009..6ecbfd49cd37081dbce722d24d9112d3805c580c 100644 (file)
@@ -196,10 +196,12 @@ class VideoHardware:
                print "saveMode", port, mode, rate
                config.av.videoport.value = port
                config.av.videoport.save()
                print "saveMode", port, mode, rate
                config.av.videoport.value = port
                config.av.videoport.save()
-               config.av.videomode[port].value = mode
-               config.av.videomode[port].save()
-               config.av.videorate[mode].value = rate
-               config.av.videorate[mode].save()
+               if port in config.av.videomode:
+                       config.av.videomode[port].value = mode
+                       config.av.videomode[port].save()
+               if mode in config.av.videorate:
+                       config.av.videorate[mode].value = rate
+                       config.av.videorate[mode].save()
 
        def isPortAvailable(self, port):
                # fixme
 
        def isPortAvailable(self, port):
                # fixme
index 73b07acf5b07c72caa136fee76e2068ffd297c7d..54e241decef3e9a5553a090f963112e85dfde3ba 100644 (file)
@@ -25,9 +25,10 @@ class DefaultWizard(WizardLanguage, DreamInfoHandler):
                self["arrowup2"] = MovingPixmap()
        
        def setDirectory(self):
                self["arrowup2"] = MovingPixmap()
        
        def setDirectory(self):
-               os_system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
                self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
                self.xmlfile = "defaultwizard.xml"
                self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
                self.xmlfile = "defaultwizard.xml"
+               if self.directory:
+                       os_system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), self.directory))
         
        def markDone(self):
                config.misc.defaultchosen.value = 0
         
        def markDone(self):
                config.misc.defaultchosen.value = 0
index 8e4d0044fc6043d4ef00f17e6ba15828cabd21f4..f0ef0de22a3dfd6acca870adc069d270b29c029d 100755 (executable)
@@ -118,7 +118,11 @@ def resolveFilename(scope, base = "", path_prefix = None):
 
        if flags == PATH_CREATE:
                if not pathExists(path):
 
        if flags == PATH_CREATE:
                if not pathExists(path):
-                       mkdir(path)
+                       try:
+                               mkdir(path)
+                       except OSError:
+                               print "resolveFilename: Couldn't create %s" % path
+                               return None
 
        fallbackPath = fallbackPaths.get(scope)
 
 
        fallbackPath = fallbackPaths.get(scope)
 
@@ -224,12 +228,13 @@ def InitFallbackFiles():
 # returns a list of tuples containing pathname and filename matching the given pattern
 # example-pattern: match all txt-files: ".*\.txt$"
 def crawlDirectory(directory, pattern):
 # returns a list of tuples containing pathname and filename matching the given pattern
 # example-pattern: match all txt-files: ".*\.txt$"
 def crawlDirectory(directory, pattern):
-       expression = compile(pattern)
        list = []
        list = []
-       for root, dirs, files in walk(directory):
-               for file in files:
-                       if expression.match(file) is not None:
-                               list.append((root, file))
+       if directory:
+               expression = compile(pattern)
+               for root, dirs, files in walk(directory):
+                       for file in files:
+                               if expression.match(file) is not None:
+                                       list.append((root, file))
        return list
 
 def copyfile(src, dst):
        return list
 
 def copyfile(src, dst):