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


Python CFG.serialize方法代码示例

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


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

示例1: CFG

# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import serialize [as 别名]
from DIRAC.Core.Utilities.CFG import CFG

DIRAC.gLogger.initialize('test_gConfig','/testSectionDebug')

testconfig = '%s/DIRAC/ConfigurationSystem/test/test.cfg' % DIRAC.rootPath
dumpconfig = '%s/DIRAC/ConfigurationSystem/test/dump.cfg' % DIRAC.rootPath

cfg1 = CFG()
cfg1.loadFromFile( testconfig )

fd = file( testconfig )
cfg1String = fd.read()
fd.close()

cfg2 = CFG()
cfg2.loadFromBuffer( cfg1.serialize() )

cfg3 = cfg1.mergeWith( cfg2 )

testList = [{ 'method'    : DIRAC.gConfig.loadFile,
              'arguments' : ( testconfig, ),
              'output'    : {'OK': True, 'Value': ''}
            },
            { 'method'    : DIRAC.gConfig.dumpLocalCFGToFile,
              'arguments' : ( dumpconfig, ),
              'output'    : {'OK': True, 'Value': ''}
            },
            { 'method'    : cfg1.serialize,
              'arguments' : ( ),
              'output'    : cfg1String
            },
开发者ID:sbel,项目名称:bes3-jinr,代码行数:33,代码来源:test_gCFG.py

示例2: convertSites

# 需要导入模块: from DIRAC.Core.Utilities.CFG import CFG [as 别名]
# 或者: from DIRAC.Core.Utilities.CFG.CFG import serialize [as 别名]
def convertSites():
  
  global csapi
  
  gLogger.notice( 'Converting Computing services' )
  
  # Collect site info
  infoDict = {}
  result = gConfig.getSections( '/Resources/Sites' ) 
  
  print result
  
  if not result['OK']:
    return result
  domains = result['Value']
  for domain in domains:
    gLogger.notice( 'Analyzing domain %s' % domain )
    result = gConfig.getSections( '/Resources/Sites/%s' % domain )
    if not result['OK']:
      return result 
    sites = result['Value']
    for site in sites:
      result = getSiteName( site )
      if not result['OK']:
        gLogger.error( 'Invalid site name %s' % site )
        continue
      siteName = result['Value']
      country = result['Country']
      
      print "AT >>> siteName, country", siteName, country
      
      gLogger.notice( 'Analyzing site %s' % siteName )
      result = gConfig.getOptionsDict( '/Resources/Sites/%s/%s' % (domain,site) )
      if not result['OK']:
        return result 
      siteDict = result['Value']
      siteDict['Country'] = country
      if 'Name' in siteDict:
        siteDict['GOCName'] = siteDict['Name']
        del siteDict['Name']
      if "CE" in siteDict:
        del siteDict['CE']
      if 'SE' in siteDict:
        del siteDict['SE']  
      infoDict.setdefault( siteName, siteDict )
      infoDict[siteName].setdefault( 'Domain', [] )
      infoDict[siteName]['Domain'].append( domain )
      if 'VO' in siteDict:
        communities = List.fromChar( siteDict['VO'] )
        infoDict[siteName]['VO'] = communities
      result = gConfig.getSections('/Resources/Sites/%s/%s/CEs' % (domain,site))
      if not result['OK']:
        if 'does not exist' in result['Message']:
          continue
        return result
      ces = result['Value']
      for ce in ces:
        result = gConfig.getOptionsDict( '/Resources/Sites/%s/%s/CEs/%s' % (domain,site,ce) )
        if not result['OK']:
          return result 
        ceDict = result['Value']
        
        ceName = ce.split('.')[0]
        if not 'Host' in ceDict:
          ceDict['Host'] = ce
        if not "SubmissionMode" in ceDict or ceDict['SubmissionMode'].lower() != "direct":
          ceDict['SubmissionMode'] = 'gLite'   
        
        infoDict[siteName].setdefault( 'Computing', {} )
        infoDict[siteName]['Computing'][ceName] = ceDict
        if 'VO' in ceDict:
          communities = List.fromChar( ceDict['VO'] )
          infoDict[siteName]['Computing'][ceName]['VO'] = communities
          del ceDict['VO']
        result = gConfig.getSections('/Resources/Sites/%s/%s/CEs/%s/Queues' % (domain,site,ce))
        if not result['OK']:
          if 'does not exist' in result['Message']:
            continue
          return result
        queues = result['Value']
        for queue in queues:
          result = gConfig.getOptionsDict( '/Resources/Sites/%s/%s/CEs/%s/Queues/%s' % (domain,site,ce,queue) )
          if not result['OK']:
            return result 
          queueDict = result['Value']
          infoDict[siteName]['Computing'][ceName].setdefault( 'Queues', {} )
          infoDict[siteName]['Computing'][ceName]['Queues'][queue] = queueDict
          if 'VO' in queueDict:
            communities = List.fromChar( queueDict['VO'] )
            infoDict[siteName]['Computing'][ceName]['Queues'][queue]['VO'] = communities
            del queueDict['VO']
        
      cfg = CFG()
      cfg.loadFromDict( infoDict[siteName] )
      
      print "AT >>> siteName, cfg", siteName, cfg.serialize()
      
      csapi.mergeCFGUnderSection( '%s/Sites/%s' % (RESOURCES_NEW_SECTION,siteName), cfg)
      csapi.sortSection( '%s/Sites/%s/Computing' % (RESOURCES_NEW_SECTION,siteName) )
             
#.........这里部分代码省略.........
开发者ID:graciani,项目名称:DIRAC,代码行数:103,代码来源:dirac-configuration-convert-resources-schema.py


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