Example #1
0
 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
Example #2
0
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 )
Example #3
0
    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)
Example #4
0
  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)