Esempio n. 1
0
    def __processFiles(self,
                       path,
                       spacecraft,
                       procpath,
                       collection,
                       checkLoadable=True):

        if not os.path.isdir(path):
            LOG("Discarding file: " + path)
            return

        if not path in sys.path:
            LOG("Append python path: " + path)
            sys.path.append(path)

        filelist = os.listdir(path)
        for procfile in filelist:
            thefile = os.path.splitext(procfile)
            if thefile[1] == '.py' and thefile[0] != "__init__":
                try:
                    self.__parser.parseFile(path + os.sep + procfile)
                except ParseError, e:
                    LOG(e.message + ": " + procfile)
                    continue
                except NotLoadable, e:
                    LOG(e.message + ": " + procfile)
                    continue

                fullpath = path + os.sep + procfile
                procId = fullpath.split(procpath)[1][1:][:-3]
                theProcedure = Procedure(procId, self.__parser.properties(),
                                         fullpath)

                if self.__isDomainApplicable(theProcedure, spacecraft):
                    collection[procId] = theProcedure
                    self.__filenameToId[fullpath] = procId
                    procName = theProcedure.name()
                    id = procId + "|" + procName
                    if checkLoadable and theProcedure.isLoadable()\
                       and not id in self.__loadableProcedures:
                        self.__loadableProcedures.append(id)
                else:
                    LOG("Discarding procedure: " + procId)
Esempio n. 2
0
    def __processFiles(self, path, spacecraft, procpath, collection, checkLoadable = True ):
    
        if not os.path.isdir(path):
            LOG("Discarding file: " + path)
            return

        if not path in sys.path:
            LOG("Append python path: " + path)
            sys.path.append( path )
        
        filelist = os.listdir(path)
        for procfile in filelist:
            thefile = os.path.splitext(procfile)
            if thefile[1] == '.py' and thefile[0] != "__init__":
                try:
                    self.__parser.parseFile( path + os.sep + procfile)
                except ParseError,e:
                    LOG(e.message + ": " + procfile)
                    continue
                except NotLoadable,e:
                    LOG(e.message + ": " + procfile)
                    continue
                
                fullpath = path + os.sep + procfile
                procId = fullpath.split( procpath )[1][1:][:-3]
                theProcedure = Procedure(procId, self.__parser.properties(), fullpath)

                if self.__isDomainApplicable(theProcedure, spacecraft):
                    collection[procId] = theProcedure
                    self.__filenameToId[fullpath] = procId
                    procName = theProcedure.name()
                    id = procId + "|" + procName
                    if checkLoadable and theProcedure.isLoadable()\
                       and not id in self.__loadableProcedures:
                        self.__loadableProcedures.append(id)
                else:
                    LOG("Discarding procedure: " + procId)
Esempio n. 3
0
                except NotLoadable, e:
                    LOG(e.message + ": " + procfile)
                    continue
                except:
                    LOG("Unable to read file: " + procfile, LOG_ERROR)
                    continue

                fullpath = path + os.sep + procfile
                procId = fullpath.split(procpath)[1][1:][:-3]
                theProcedure = Procedure(procId, self.__parser.properties(),
                                         fullpath)

                if self.__isDomainApplicable(theProcedure, spacecraft):
                    collection[procId] = theProcedure
                    self.__filenameToId[fullpath] = procId
                    procName = theProcedure.name()
                    id = procId + "|" + procName
                    if checkLoadable and theProcedure.isLoadable()\
                       and not id in self.__loadableProcedures:
                        self.__loadableProcedures.append(id)
                else:
                    LOG("Discarding procedure: " + procId)
            elif thefile[1] == '.pyc':
                os.remove(path + os.sep + procfile)
            elif thefile[1] == '':
                self.__processFiles(path + os.sep + thefile[0], spacecraft,
                                    procpath, collection, checkLoadable)

    #==========================================================================
    def __isDomainApplicable(self, procedureObject, spacecraft):
        spacecraft = spacecraft.strip()
Esempio n. 4
0
                    continue
                except NotLoadable,e:
                    LOG(e.message + ": " + procfile)
                    continue
                except:
                    LOG("Unable to read file: " + procfile, LOG_ERROR)
                    continue
                
                fullpath = path + os.sep + procfile
                procId = fullpath.split( procpath )[1][1:][:-3]
                theProcedure = Procedure(procId, self.__parser.properties(), fullpath)

                if self.__isDomainApplicable(theProcedure, spacecraft):
                    collection[procId] = theProcedure
                    self.__filenameToId[fullpath] = procId
                    procName = theProcedure.name()
                    id = procId + "|" + procName
                    if checkLoadable and theProcedure.isLoadable()\
                       and not id in self.__loadableProcedures:
                        self.__loadableProcedures.append(id)
                else:
                    LOG("Discarding procedure: " + procId)
            elif thefile[1]=='.pyc':
                os.remove(path + os.sep + procfile)
            elif thefile[1]=='':
                self.__processFiles( path + os.sep + thefile[0], spacecraft, procpath, collection, checkLoadable)
    
    #==========================================================================
    def __isDomainApplicable(self, procedureObject, spacecraft ):
        spacecraft = spacecraft.strip()
        if spacecraft == "STD": return True