From: Andreas Oberritter Date: Fri, 25 Mar 2011 18:58:57 +0000 (+0100) Subject: fix some crashes during settings wizard X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/2c5e4d6c412c1988b32cb7dbede988bc9dfb815d?hp=7f070068aa203cb95252b641b1c0cc5308a604ee fix some crashes during settings wizard --- diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 6e560857..5507cae9 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1661,9 +1661,12 @@ class Config(ConfigSubsection): 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") diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index dc4e8c56..6ecbfd49 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -196,10 +196,12 @@ class VideoHardware: 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 diff --git a/lib/python/Screens/DefaultWizard.py b/lib/python/Screens/DefaultWizard.py index 73b07acf..54e241de 100644 --- a/lib/python/Screens/DefaultWizard.py +++ b/lib/python/Screens/DefaultWizard.py @@ -25,9 +25,10 @@ class DefaultWizard(WizardLanguage, DreamInfoHandler): 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" + if self.directory: + os_system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), self.directory)) def markDone(self): config.misc.defaultchosen.value = 0 diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index 8e4d0044..f0ef0de2 100755 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -118,7 +118,11 @@ def resolveFilename(scope, base = "", path_prefix = None): 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) @@ -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): - expression = compile(pattern) 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):