def _loadWebAppCFGFiles(self): """ Load EiscatWeb/web.cfg definitions """ exts = [] for ext in CSGlobals.getCSExtensions(): if ext == "DIRAC": continue if ext[-5:] != "DIRAC": ext = "%sDIRAC" % ext if ext == "WebAppDIRAC": continue if ext != "EiscatWebDIRAC": exts.append(ext) exts.append("DIRAC") exts.append("EiscatWebDIRAC") print "exts in loadWebAppCFGFiles of App.py" print exts webCFG = CFG() for modName in reversed(exts): try: modPath = imp.find_module(modName)[1] except ImportError: continue gLogger.verbose("Found module %s at %s" % (modName, modPath)) cfgPath = os.path.join(modPath, "WebApp", "web.cfg") print "cfgPath" print cfgPath if not os.path.isfile(cfgPath): gLogger.verbose("Inexistant %s" % cfgPath) continue try: modCFG = CFG().loadFromFile(cfgPath) except Exception, excp: gLogger.error("Could not load %s: %s" % (cfgPath, excp)) continue gLogger.verbose("Loaded %s" % cfgPath) expl = [Conf.BASECS] while len(expl): current = expl.pop(0) if not modCFG.isSection(current): continue if modCFG.getOption("%s/AbsoluteDefinition" % current, False): gLogger.verbose("%s:%s is an absolute definition" % (modName, current)) try: webCFG.deleteKey(current) except: pass modCFG.deleteKey("%s/AbsoluteDefinition" % current) else: for sec in modCFG[current].listSections(): expl.append("%s/%s" % (current, sec)) # Add the modCFG webCFG = webCFG.mergeWith(modCFG) print "al final webCFG" print webCFG
def loadWebAppCFGFiles(): """ Load WebApp/web.cfg definitions """ exts = [] for ext in CSGlobals.getCSExtensions(): if ext == "DIRAC": continue if ext[-5:] != "DIRAC": ext = "%sDIRAC" % ext if ext != "WebAppDIRAC": exts.append( ext ) exts.append( "DIRAC" ) exts.append( "WebAppDIRAC" ) webCFG = CFG() for modName in reversed( exts ): try: modPath = imp.find_module( modName )[1] except ImportError: continue gLogger.verbose( "Found module %s at %s" % ( modName, modPath ) ) cfgPath = os.path.join( modPath, "WebApp", "web.cfg" ) if not os.path.isfile( cfgPath ): gLogger.verbose( "Inexistant %s" % cfgPath ) continue try: modCFG = CFG().loadFromFile( cfgPath ) except Exception, excp: gLogger.error( "Could not load %s: %s" % ( cfgPath, excp ) ) continue gLogger.verbose( "Loaded %s" % cfgPath ) expl = [ BASECS ] while len( expl ): current = expl.pop( 0 ) if not modCFG.isSection( current ): continue if modCFG.getOption( "%s/AbsoluteDefinition" % current, False ): gLogger.verbose( "%s:%s is an absolute definition" % ( modName, current ) ) try: webCFG.deleteKey( current ) except: pass modCFG.deleteKey( "%s/AbsoluteDefinition" % current ) else: for sec in modCFG[ current ].listSections(): expl.append( "%s/%s" % ( current, sec ) ) #Add the modCFG webCFG = webCFG.mergeWith( modCFG )
def _loadWebAppCFGFiles(self, extension): """ Load WebApp/web.cfg definitions :param str extension: the module name of the extension of WebAppDirac for example: LHCbWebDIRAC """ exts = [extension, "WebAppDIRAC"] webCFG = CFG() for modName in reversed(exts): cfgPath = os.path.join(self.__params.destination, "%s/WebApp" % modName, "web.cfg") if not os.path.isfile(cfgPath): gLogger.verbose("Web configuration file %s does not exists!" % cfgPath) continue try: modCFG = CFG().loadFromFile(cfgPath) except Exception, excp: gLogger.error("Could not load %s: %s" % (cfgPath, excp)) continue gLogger.verbose("Loaded %s" % cfgPath) expl = ["/WebApp"] while len(expl): current = expl.pop(0) if not modCFG.isSection(current): continue if modCFG.getOption("%s/AbsoluteDefinition" % current, False): gLogger.verbose("%s:%s is an absolute definition" % (modName, current)) try: webCFG.deleteKey(current) except: pass modCFG.deleteKey("%s/AbsoluteDefinition" % current) else: for sec in modCFG[current].listSections(): expl.append("%s/%s" % (current, sec)) # Add the modCFG webCFG = webCFG.mergeWith(modCFG)
if instType.find("client") == 0: gLogger.error("Client installations do not support externals requirements") sys.exit(0) for entry in os.listdir(rootPath): if len(entry) < 5 or entry.find("DIRAC") != len(entry) - 5: continue reqFile = os.path.join(rootPath, entry, "releases.cfg") try: with open(reqFile, "r") as extfd: reqCFG = CFG().loadFromBuffer(extfd.read()) except: gLogger.warn("%s not found" % reqFile) continue reqs = reqCFG.getOption("/RequiredExternals/%s" % instType.capitalize(), []) if not reqs: gLogger.warn("%s does not have requirements for %s installation" % (entry, instType)) continue for req in reqs: reqName = False reqCond = "" for cond in ("==", ">="): iP = cond.find(req) if iP > 0: reqName = req[:iP] reqCond = req[iP:] break if not reqName: reqName = req
if instType.find("client") == 0: gLogger.error("Client installations do not support externals requirements") sys.exit(0) for entry in os.listdir(rootPath): if len(entry) < 5 or entry.find("DIRAC") != len(entry) - 5: continue reqFile = os.path.join(rootPath, entry, "releases.cfg") try: extfd = open(reqFile, "r") except: gLogger.warn("%s not found" % reqFile) continue reqCFG = CFG().loadFromBuffer(extfd.read()) extfd.close() reqs = reqCFG.getOption("/RequiredExternals/%s" % instType.capitalize(), []) if not reqs: gLogger.warn("%s does not have requirements for %s installation" % (entry, instType)) continue for req in reqs: reqName = False reqCond = "" for cond in ("==", ">="): iP = cond.find(req) if iP > 0: reqName = req[:iP] reqCond = req[iP:] break if not reqName: reqName = req if reqName not in reqDict: