allow installing from multiple directories
[enigma2.git] / lib / python / Components / DreamInfoHandler.py
index 8220b8b..858b99a 100644 (file)
@@ -31,7 +31,7 @@ class InfoHandler(xml.sax.ContentHandler):
        def startElement(self, name, attrs):
                print name, ":", attrs.items()
                self.elements.append(name)
-               if name in ["hardware", "bcastsystem", "satellite"]:
+               if name in ["hardware", "bcastsystem", "satellite", "tag"]:
                        if not attrs.has_key("type"):
                                        self.printError(str(name) + " tag with no type attribute")
                        if self.elements[-3] == "default":
@@ -97,9 +97,11 @@ class DreamInfoHandler:
        STATUS_ERROR = 2
        STATUS_INIT = 4
        
-       def __init__(self, statusCallback, blocking = False):
+       def __init__(self, statusCallback, blocking = False, neededTag = None):
                self.directory = "/"
                
+               self.neededTag = neededTag
+               
                # caution: blocking should only be used, if further execution in enigma2 depends on the outcome of
                # the installer!
                self.blocking = blocking
@@ -128,7 +130,13 @@ class DreamInfoHandler:
        # prerequisites = True: give only packages matching the prerequisites
        def fillPackagesList(self, prerequisites = True):
                self.packageslist = []
-               packages = crawlDirectory(self.directory, ".*\.info$")
+               packages = []
+               if not isinstance(self.directory, list):
+                       self.directory = [self.directory]
+               
+               for directory in self.directory:
+                       packages += crawlDirectory(directory, ".*\.info$")
+
                for package in packages:
                        self.readInfo(package[0] + "/", package[0] + "/" + package[1])
                        
@@ -142,6 +150,18 @@ class DreamInfoHandler:
                # TODO: we need to implement a hardware detection here...
                print "prerequisites:", prerequisites
                met = True
+               if self.neededTag is None:
+                       if prerequisites.has_key("tag"):
+                               return False
+               else:
+                       if prerequisites.has_key("tag"):
+                               if not self.neededTag in prerequisites["tag"]:
+                                       return False
+                               
+               if prerequisites.has_key("satellite"):
+                       for sat in prerequisites["satellite"]:
+                               if int(sat) not in nimmanager.getConfiguredSats():
+                                       return False                            
                if prerequisites.has_key("bcastsystem"):
                        for bcastsystem in prerequisites["bcastsystem"]:
                                if nimmanager.hasNimType(bcastsystem):
@@ -183,10 +203,13 @@ class DreamInfoHandler:
                #print "attributes:", attributes
                
                if self.currentAttributeIndex >= len(self.attributeNames): # end of package reached
+                       print "end of package reached"
                        if self.currentlyInstallingMetaIndex is None or self.currentlyInstallingMetaIndex >= len(self.installIndexes) - 1:
+                               print "set status to DONE"
                                self.setStatus(self.STATUS_DONE)
                                return
                        else:
+                               print "increment meta index to install next package"
                                self.currentlyInstallingMetaIndex += 1
                                self.installPackage(self.installIndexes[self.currentlyInstallingMetaIndex])
                
@@ -203,6 +226,7 @@ class DreamInfoHandler:
                                self.installNext()
                                return
                else: # nothing to install here
+                       self.currentIndex = -1
                        self.currentAttributeIndex += 1
                        self.installNext()
                        return
@@ -270,11 +294,11 @@ class DreamInfoHandler:
 
        def mergeServices(self, directory, name, merge = False):
                print "merging services:", directory, " - ", name
-               
-               db = eDVBDB.getInstance()
-               db.reloadServicelist()
-               db.loadServicelist(directory + name)
-               db.saveServicelist()
+               if os.path.isfile(directory + name):
+                       db = eDVBDB.getInstance()
+                       db.reloadServicelist()
+                       db.loadServicelist(directory + name)
+                       db.saveServicelist()
                self.installNext()
 
        def installFavourites(self, directory, name):