本文整理汇总了Python中DIRAC.ConfigurationSystem.Client.Helpers.CSGlobals类的典型用法代码示例。如果您正苦于以下问题:Python CSGlobals类的具体用法?Python CSGlobals怎么用?Python CSGlobals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSGlobals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getOpsSection
def getOpsSection():
"""
Where is the shifters section?
"""
vo = CSGlobals.getVO()
setup = CSGlobals.getSetup()
if vo:
res = gConfig.getSections( '/Operations/%s/%s/Shifter' % (vo, setup) )
if res['OK']:
return S_OK( '/Operations/%s/%s/Shifter' % ( vo, setup ) )
res = gConfig.getSections( '/Operations/%s/Defaults/Shifter' % vo )
if res['OK']:
return S_OK( '/Operations/%s/Defaults/Shifter' % vo )
else:
res = gConfig.getSections( '/Operations/%s/Shifter' % setup )
if res['OK']:
return S_OK( '/Operations/%s/Shifter' % setup )
res = gConfig.getSections( '/Operations/Defaults/Shifter' )
if res['OK']:
return S_OK( '/Operations/Defaults/Shifter' )
return S_ERROR( "No shifter section" )
示例2: __getSearchPaths
def __getSearchPaths( self ):
paths = [ "/Operations/Defaults", "/Operations/%s" % self.__setup ]
if not self.__vo:
globalVO = CSGlobals.getVO()
if not globalVO:
return paths
self.__vo = CSGlobals.getVO()
paths.append( "/Operations/%s/Defaults" % self.__vo )
paths.append( "/Operations/%s/%s" % ( self.__vo, self.__setup ) )
return paths
示例3: __getInstallFlags
def __getInstallFlags(self):
""" Get the flags to pass to dirac-install.py inside the container.
Returns a string containing the command line flags.
"""
instOpts = []
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
opsHelper = Operations.Operations(setup=setup)
installationName = opsHelper.getValue("Pilot/Installation", "")
if installationName:
instOpts.append('-V %s' % installationName)
diracVersions = opsHelper.getValue("Pilot/Version", [])
instOpts.append("-r '%s'" % diracVersions[0])
pyVer = "%u%u" % (sys.version_info.major, sys.version_info.minor)
instOpts.append("-i %s" % pyVer)
pilotExtensionsList = opsHelper.getValue("Pilot/Extensions", [])
extensionsList = []
if pilotExtensionsList:
if pilotExtensionsList[0] != 'None':
extensionsList = pilotExtensionsList
else:
extensionsList = CSGlobals.getCSExtensions()
if extensionsList:
instOpts.append("-e '%s'" % ','.join([ext for ext in extensionsList if 'Web' not in ext]))
if 'ContainerExtraOpts' in self.ceParameters:
instOpts.append(self.ceParameters['ContainerExtraOpts'])
return ' '.join(instOpts)
示例4: _curlDownload
def _curlDownload( self, granularity, site, tests ):
""" Download SAM status for entity using the SAM DB programmatic interface
"""
samdbpi_url = "http://lcg-sam.cern.ch:8080/same-pi/"
# Set your method
if granularity in ( 'Site', 'Sites' ):
samdbpi_method = "site_status.jsp?"
elif granularity in ( 'Resource', 'Resources' ):
samdbpi_method = "service_endpoint_status.jsp?"
# Set your site
samdbpi_site = site
# set test
samdbpi_test = ""
if tests is None:
samdbpi_test = "&only_ss"
extension = CSGlobals.getCSExtensions()[0]
samdb_ep = samdbpi_url + samdbpi_method + "VO_name=" + extension + "&Site_name=" + samdbpi_site + samdbpi_test
req = urllib2.Request( samdb_ep )
samPage = urllib2.urlopen( req )
sam = samPage.read()
return sam
示例5: __discoverSettings
def __discoverSettings( self ):
#Set the VO
globalVO = CSGlobals.getVO()
if globalVO:
self.__vo = globalVO
elif self.__uVO:
self.__vo = self.__uVO
else:
self.__vo = Registry.getVOForGroup( self.__uGroup )
if not self.__vo:
self.__vo = False
#Set the setup
self.__setup = False
if self.__uSetup:
self.__setup = self.__uSetup
else:
self.__setup = CSGlobals.getSetup()
示例6: __generateRootModules
def __generateRootModules( self, baseModules ):
""" Iterate over all the possible root modules
"""
self.__rootModules = baseModules
for rootModule in reversed( CSGlobals.getCSExtensions() ):
if rootModule[-5:] != "DIRAC" and rootModule not in self.__rootModules:
self.__rootModules.append( "%sDIRAC" % rootModule )
self.__rootModules.append( "" )
示例7: __rootModules
def __rootModules( self ):
""" Iterate over all the possible root modules
"""
for rootModule in CSGlobals.getCSExtensions():
if rootModule[-5:] != "DIRAC":
rootModule = "%sDIRAC" % rootModule
yield rootModule
yield 'DIRAC'
yield ''
示例8: __discoverSettings
def __discoverSettings( self ):
#Set the VO
globalVO = CSGlobals.getVO()
if globalVO:
self.__vo = globalVO
elif self.__uVO:
self.__vo = self.__uVO
else:
self.__vo = Registry.getVOForGroup( self.__uGroup )
if not self.__vo:
self.__vo = None
示例9: __generateRootModules
def __generateRootModules( self, baseModules ):
""" Iterate over all the possible root modules
"""
self.__rootModules = baseModules
for rootModule in reversed( CSGlobals.getCSExtensions() ):
if rootModule[-5:] != "DIRAC" and rootModule not in self.__rootModules:
self.__rootModules.append( "%sDIRAC" % rootModule )
self.__rootModules.append( "" )
# Reversing the order because we want first to look in the extension(s)
self.__rootModules.reverse()
示例10: includeExtensionErrors
def includeExtensionErrors():
""" Merge all the errors of all the extensions into the errors of these modules
Should be called only at the initialization of DIRAC, so by the parseCommandLine,
dirac-agent.py, dirac-service.py, dirac-executor.py
"""
def __recurseImport( modName, parentModule = None, fullName = False ):
""" Internal function to load modules
"""
if isinstance( modName, basestring ):
modName = modName.split( "." )
if not fullName:
fullName = ".".join( modName )
try:
if parentModule:
impData = imp.find_module( modName[0], parentModule.__path__ )
else:
impData = imp.find_module( modName[0] )
impModule = imp.load_module( modName[0], *impData )
if impData[0]:
impData[0].close()
except ImportError:
return None
if len( modName ) == 1:
return impModule
return __recurseImport( modName[1:], impModule, fullName = fullName )
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals
allExtensions = CSGlobals.getCSExtensions()
for extension in allExtensions:
ext_derrno = None
try:
ext_derrno = __recurseImport( '%sDIRAC.Core.Utilities.DErrno' % extension )
if ext_derrno:
# The next 3 dictionary MUST be present for consistency
# Global name of errors
sys.modules[__name__].__dict__.update( ext_derrno.extra_dErrName )
# Dictionary with the error codes
sys.modules[__name__].dErrorCode.update( ext_derrno.extra_dErrorCode )
# Error description string
sys.modules[__name__].dStrError.update( ext_derrno.extra_dStrError )
# extra_compatErrorString is optional
for err in getattr( ext_derrno, 'extra_compatErrorString', [] ) :
sys.modules[__name__].compatErrorString.setdefault( err, [] ).extend( ext_derrno.extra_compatErrorString[err] )
except:
pass
示例11: __discoverSettings
def __discoverSettings( self ):
#Set the VO
globalVO = CSGlobals.getVO()
if globalVO:
self.__vo = globalVO
elif self.__uVO:
self.__vo = self.__uVO
elif self.__uGroup:
self.__vo = Registry.getVOForGroup( self.__uGroup )
if not self.__vo:
self.__vo = False
else:
result = getVOfromProxyGroup()
if result['OK']:
self.__vo = result['Value']
#Set the setup
self.__setup = False
if self.__uSetup:
self.__setup = self.__uSetup
else:
self.__setup = CSGlobals.getSetup()
示例12: setHandlers
def setHandlers( cls, handlers ):
cls.__handlers = {}
for k in handlers:
handler = handlers[ k ]
cls.__handlers[ handler.LOCATION.strip("/") ] = handler
#Calculate extensions
cls.__extensions = []
for ext in CSGlobals.getInstalledExtensions():
if ext in ( "WebAppDIRAC", "DIRAC" ):
continue
cls.__extensions.append( ext )
cls.__extensions.append( "DIRAC" )
cls.__extensions.append( "WebAppDIRAC" )
示例13: __discoverSettings
def __discoverSettings( self ):
#Set the VO
self.__threadData.vo = False
if self.__threadData.uVO:
self.__threadData.vo = self.__threadData.uVO
else:
self.__threadData.vo = Registry.getVOForGroup( self.__threadData.uGroup )
if not self.__threadData.vo:
raise RuntimeError( "Don't know how to discover VO. Please check your VO and groups configuration" )
#Set the setup
self.__threadData.setup = False
if self.__threadData.uSetup:
self.__threadData.setup = self.__threadData.uSetup
else:
self.__threadData.setup = CSGlobals.getSetup()
示例14: 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 )
示例15: getPaths
def getPaths( self, dirName ):
"""
Get lists of paths for all installed and enabled extensions
"""
pathList = []
for extName in CSGlobals.getCSExtensions():
if extName.rfind( "DIRAC" ) != len( extName ) - 5:
extName = "%sDIRAC" % extName
if extName == "WebAppDIRAC":
continue
try:
modFile, modPath, desc = imp.find_module( extName )
except ImportError:
continue
staticPath = os.path.join( modPath, "WebApp", dirName )
if os.path.isdir( staticPath ):
pathList.append( staticPath )
#Add WebAppDirac to the end
pathList.append( os.path.join( WebAppDIRAC.rootPath, "WebApp", dirName ) )
return pathList