当前位置: 首页>>代码示例>>Python>>正文


Python CFG.getOption方法代码示例

本文整理汇总了Python中DIRAC.Core.Utilities.CFG.CFG.getOption方法的典型用法代码示例。如果您正苦于以下问题:Python CFG.getOption方法的具体用法?Python CFG.getOption怎么用?Python CFG.getOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Core.Utilities.CFG.CFG的用法示例。


在下文中一共展示了CFG.getOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadWebAppCFGFiles

# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import getOption [as 别名]
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 )
开发者ID:DIRACGrid,项目名称:WebAppDIRAC,代码行数:50,代码来源:ConfMgr.py

示例2: _loadWebAppCFGFiles

# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import getOption [as 别名]
  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)
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:38,代码来源:WebAppCompiler.py

示例3: len

# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import getOption [as 别名]
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:
开发者ID:sbel,项目名称:bes3-jinr,代码行数:33,代码来源:dirac-externals-requirements.py


注:本文中的DIRAC.Core.Utilities.CFG.CFG.getOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。