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


Python CFG.CFG类代码示例

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


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

示例1: _getCurrentConfig

  def _getCurrentConfig(self):
    """Return the current system configuration."""
    from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
    gConfig.forceRefresh()

    fullCfg = CFG()
    setup = gConfig.getValue('/DIRAC/Setup', '')
    setupList = gConfig.getSections('/DIRAC/Setups', [])
    if not setupList['OK']:
      return S_ERROR('Could not get /DIRAC/Setups sections')
    setupList = setupList['Value']
    if setup not in setupList:
      return S_ERROR('Setup %s is not in allowed list: %s' % (setup, ', '.join(setupList)))
    serviceSetups = gConfig.getOptionsDict('/DIRAC/Setups/%s' % setup)
    if not serviceSetups['OK']:
      return S_ERROR('Could not get /DIRAC/Setups/%s options' % setup)
    serviceSetups = serviceSetups['Value']  # dict
    for system, setup in serviceSetups.items():
      if self.systems and system not in self.systems:
        continue
      systemCfg = gConfigurationData.remoteCFG.getAsCFG("/Systems/%s/%s" % (system, setup))
      for section in systemCfg.listSections():
        if section not in ('Agents', 'Services', 'Executors'):
          systemCfg.deleteKey(section)

      fullCfg.createNewSection("/%s" % system, contents=systemCfg)

    return S_OK(fullCfg)
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:28,代码来源:dirac-admin-check-config-options.py

示例2: loadFile

 def loadFile( self, fileName ):
   try:
     fileCFG = CFG()
     fileCFG.loadFromFile( fileName )
   except IOError:
     self.localCFG = self.localCFG.mergeWith( fileCFG )
     return S_ERROR( "Can't load a cfg file '%s'" % fileName )
   return self.mergeWithLocal( fileCFG )
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:8,代码来源:ConfigurationData.py

示例3: mergeWithServer

 def mergeWithServer( self ):
   retVal = self.rpcClient.getCompressedData()
   if retVal[ 'OK' ]:
     remoteCFG = CFG()
     remoteCFG.loadFromBuffer( zlib.decompress( retVal[ 'Value' ] ) )
     serverVersion = gConfigurationData.getVersion( remoteCFG )
     self.cfgData = remoteCFG.mergeWith( self.cfgData )
     gConfigurationData.setVersion( serverVersion, self.cfgData )
   return retVal
开发者ID:ahaupt,项目名称:DIRAC,代码行数:9,代码来源:Modificator.py

示例4: _parseConfigTemplate

  def _parseConfigTemplate(self, templatePath, cfg=None):
    """Parse the ConfigTemplate.cfg files.

    :param str templatePath: path to the folder containing a ConfigTemplate.cfg file
    :param CFG cfg: cfg to merge with the systems config
    :returns: CFG object
    """
    cfg = CFG() if cfg is None else cfg

    system = os.path.split(templatePath.rstrip("/"))[1]
    if system.lower().endswith('system'):
      system = system[:-len('System')]

    if self.systems and system not in self.systems:
      return S_OK(cfg)

    templatePath = os.path.join(templatePath, 'ConfigTemplate.cfg')
    if not os.path.exists(templatePath):
      return S_ERROR("File not found: %s" % templatePath)

    loadCfg = CFG()
    loadCfg.loadFromFile(templatePath)

    newCfg = CFG()
    newCfg.createNewSection("/%s" % system, contents=loadCfg)

    cfg = cfg.mergeWith(newCfg)

    return S_OK(cfg)
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:29,代码来源:dirac-admin-check-config-options.py

示例5: JobManifest

class JobManifest( object ):

  def __init__( self, manifest = "" ):
    self.__manifest = CFG()
    self.__dirty = False
    if manifest:
      result = self.loadManifest( manifest )
      if not result[ 'OK' ]:
        raise Exception( result[ 'Message' ] )

  def isDirty( self ):
    return self.__dirty

  def setDirty( self ):
    self.__dirty = True

  def clearDirty( self ):
    self.__dirty = False

  def load( self, dataString ):
    """
    Auto discover format type based on [ .. ] of JDL
    """
    dataString = dataString.strip()
    if dataString[0] == "[" and dataString[-1] == "]":
      return self.loadJDL( dataString )
    else:
      return self.loadCFG( dataString )

  def loadJDL( self, jdlString ):
    """
    Load job manifest from JDL format
    """
    result = loadJDLAsCFG( jdlString.strip() )
    if not result[ 'OK' ]:
      self.__manifest = CFG()
      return result
    self.__manifest = result[ 'Value' ][0]
    return S_OK()

  def loadCFG( self, cfgString ):
    """
    Load job manifest from CFG format
    """
    try:
      self.__manifest.loadFromBuffer( cfgString )
    except Exception, e:
      return S_ERROR( "Can't load manifest from cfg: %s" % str( e ) )
    return S_OK()
开发者ID:cgrefe,项目名称:DIRAC,代码行数:49,代码来源:JobManifest.py

示例6: showTextConfiguration

 def showTextConfiguration(self):
     response.headers["Content-type"] = "text/plain"
     if "download" in request.params and request.params["download"] in ("yes", "true", "1"):
         version = ""
         try:
             cfg = CFG()
             cfg.loadFromBuffer(session["cfgData"])
             cfg = cfg["DIRAC"]["Configuration"]
             version = ".%s.%s" % (cfg["Name"], cfg["Version"].replace(":", "").replace("-", ""))
         except Exception, e:
             print e
         print 'attachment; filename="cs%s.cfg"' % version.replace(" ", "_")
         response.headers["Content-Disposition"] = 'attachment; filename="cs%s.cfg"' % version.replace(" ", "")
         response.headers["Content-Length"] = len(session["cfgData"])
         response.headers["Content-Transfer-Encoding"] = "Binary"
开发者ID:sfayer,项目名称:DIRACWeb,代码行数:15,代码来源:configuration.py

示例7: __init__

 def __init__( self, rpcClient = False, commiterId = "unknown" ):
   self.commiterTag = "@@-"
   self.commiterId = commiterId
   self.cfgData = CFG()
   self.rpcClient = None
   if rpcClient:
     self.setRPCClient( rpcClient )
开发者ID:ahaupt,项目名称:DIRAC,代码行数:7,代码来源:Modificator.py

示例8: __init__

 def __init__( self, manifest = "" ):
   self.__manifest = CFG()
   self.__dirty = False
   if manifest:
     result = self.loadManifest( manifest )
     if not result[ 'OK' ]:
       raise Exception( result[ 'Message' ] )
开发者ID:cgrefe,项目名称:DIRAC,代码行数:7,代码来源:JobManifest.py

示例9: appendToRepository

 def appendToRepository( self, repoLocation ):
   if not os.path.exists( repoLocation ):
     gLogger.error( "Secondary repository does not exist", repoLocation )
     return S_ERROR( "Secondary repository does not exist" )
   self.repo = CFG().loadFromFile( repoLocation ).mergeWith( self.repo )
   self._writeRepository( self.location )
   return S_OK()
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:7,代码来源:JobRepository.py

示例10: __init__

 def __init__(self, manifest=""):
     self.__manifest = CFG()
     self.__dirty = False
     self.__ops = False
     if manifest:
         result = self.load(manifest)
         if not result["OK"]:
             raise Exception(result["Message"])
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:8,代码来源:JobManifest.py

示例11: __init__

 def __init__(self, location):
   self.cfg = CFG()
   self.location = location
   self.OK = True
   if os.path.exists(self.location):
     self.cfg.loadFromFile(self.location)
     if not self.cfg.existsKey('Processes'):
       self.cfg.createNewSection('Processes')
   else:
     self.OK = False  
开发者ID:LCDgit,项目名称:ILCDIRAC,代码行数:10,代码来源:ProcessList.py

示例12: loadDescriptionFromJDL

 def loadDescriptionFromJDL( self, jdlString ):
   """
   Load job description from JDL format
   """
   result = loadJDLAsCFG( jdlString.strip() )
   if not result[ 'OK' ]:
     self.__description = CFG()
     return result
   self.__description = result[ 'Value' ][0]
   return S_OK()
开发者ID:sbel,项目名称:bes3-jinr,代码行数:10,代码来源:JobDescription.py

示例13: setUp

  def setUp( self ):
    self.authMgr = AuthManager( '/Systems/Service/Authorization' )
    cfg = CFG()
    cfg.loadFromBuffer( testSystemsCFG )
    gConfig.loadCFG( cfg )
    cfg.loadFromBuffer( testRegistryCFG )
    gConfig.loadCFG( cfg )

    self.noAuthCredDict = { 'group': 'group_test' }

    self.userCredDict = { 'DN': '/User/test/DN/CN=userA',
                          'group': 'group_test' }

    self.badUserCredDict = { 'DN': '/User/test/DN/CN=userB',
                             'group': 'group_bad' }
    self.hostCredDict = { 'DN': '/User/test/DN/CN=test.hostA.ch',
                          'group': 'hosts' }
    self.badHostCredDict = { 'DN': '/User/test/DN/CN=test.hostB.ch',
                             'group': 'hosts' }
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:19,代码来源:Test_AuthManager.py

示例14: loadJDL

 def loadJDL(self, jdlString):
     """
 Load job manifest from JDL format
 """
     result = loadJDLAsCFG(jdlString.strip())
     if not result["OK"]:
         self.__manifest = CFG()
         return result
     self.__manifest = result["Value"][0]
     return S_OK()
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:10,代码来源:JobManifest.py

示例15: loadWebAppCFGFiles

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,代码行数:48,代码来源:ConfMgr.py


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