Merge branch 'obi/master-20110329' into experimental
authorAndreas Oberritter <obi@opendreambox.org>
Tue, 29 Mar 2011 13:45:55 +0000 (15:45 +0200)
committerAndreas Oberritter <obi@opendreambox.org>
Tue, 29 Mar 2011 13:45:55 +0000 (15:45 +0200)
lib/dvb/db.cpp
lib/python/Components/PluginComponent.py
lib/python/Components/config.py
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
lib/python/Screens/DefaultWizard.py
lib/python/Tools/Directories.py

index 522035e..0547407 100644 (file)
@@ -325,19 +325,11 @@ void eDVBDB::loadServicelist(const char *file)
 {
        eDebug("---- opening lame channel db");
        FILE *f=fopen(file, "rt");
-       if (!f && strcmp(file, eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()) == 0)
-       {
-               struct stat s;
-               if ( !stat("lamedb", &s) )
-               {
-                       if ( !stat(eEnv::resolve("${sysconfdir}/enigma2").c_str(), &s) )
-                       {
-                               rename("lamedb", eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str());
-                               reloadServicelist();
-                       }
-               }
+       if (!f) {
+               eDebug("can't open %s: %m", file);
                return;
        }
+
        char line[256];
        int version=3;
        if ((!fgets(line, 256, f)) || sscanf(line, "eDVB services /%d/", &version) != 1)
@@ -623,24 +615,16 @@ void eDVBDB::loadBouquet(const char *path)
        p+=path;
        eDebug("loading bouquet... %s", p.c_str());
        FILE *fp=fopen(p.c_str(), "rt");
-       int entries=0;
        if (!fp)
        {
-               struct stat s;
-               if ( !stat(path, &s) )
-               {
-                       rename(path, p.c_str() );
-                       loadBouquet(path);
-                       return;
-               }
-               eDebug("failed to open.");
-               if ( strstr(path, "bouquets.tv") )
+               eDebug("can't open %s: %m", p.c_str());
+               if (!strcmp(path, "bouquets.tv"))
                {
                        eDebug("recreate bouquets.tv");
                        bouquet.m_bouquet_name="Bouquets (TV)";
                        bouquet.flushChanges();
                }
-               else if ( strstr(path, "bouquets.radio") )
+               else if (!strcmp(path, "bouquets.radio"))
                {
                        eDebug("recreate bouquets.radio");
                        bouquet.m_bouquet_name="Bouquets (Radio)";
@@ -648,6 +632,7 @@ void eDVBDB::loadBouquet(const char *path)
                }
                return;
        }
+       int entries=0;
        char line[256];
        bool read_descr=false;
        eServiceReference *e = NULL;
index c6ad584..b06246b 100755 (executable)
@@ -49,7 +49,6 @@ class PluginComponent:
                        directory_category = directory + c
                        if not os_path.isdir(directory_category):
                                continue
-                       open(directory_category + "/__init__.py", "a").close()
                        for pluginname in os_listdir(directory_category):
                                path = directory_category + "/" + pluginname
                                if os_path.isdir(path):
index 6e56085..5507cae 100755 (executable)
@@ -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")
index dc4e8c5..6ecbfd4 100644 (file)
@@ -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
index 73b07ac..54e241d 100644 (file)
@@ -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
index 8e4d004..f0ef0de 100755 (executable)
@@ -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):