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


Python Utilities.Utils类代码示例

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


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

示例1: getValue

def getValue(v):
  """Wrapper around gConfig.getValue. Returns typed values instead of
  a string value"""
  res = gConfig.getValue(v)
  if res.find(",") > -1: # res is a list of values
    return [Utils.typedobj_of_string(e) for e in List.fromChar(res)]
  else: return Utils.typedobj_of_string(res)
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:7,代码来源:CS.py

示例2: _getStatus

  def _getStatus(self, name, panel):

    #get RSS status
    RSSStatus = self._getInfoFromRSSDB(name, panel)[0][1]

    #get DIRAC status
    if panel in ('Site_Panel', 'SE_Panel'):

      if panel == 'Site_Panel':
        DIRACStatus = self.WMSAdmin.getSiteMaskLogging(name)
        if DIRACStatus['OK']:
          DIRACStatus = DIRACStatus['Value'][name].pop()[0]
        else:
          raise RSSException, Utils.where(self, self._getStatus)

      elif panel == 'SE_Panel':
        ra = getStorageElementStatus(name, 'ReadAccess')['Value']
        wa = getStorageElementStatus(name, 'WriteAccess')['Value']
        DIRACStatus = {'ReadAccess': ra, 'WriteAccess': wa}

      status = { name : { 'RSSStatus': RSSStatus, 'DIRACStatus': DIRACStatus } }

    else:
      status = { name : { 'RSSStatus': RSSStatus} }


    return status
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:27,代码来源:Publisher.py

示例3: getValue

def getValue( val, default ):
  '''Wrapper around gConfig.getValue. Returns typed values'''
  res = gConfig.getValue( val, default )
  if Utils.isiterable( res ):
    return [ Utils.typedobj_of_string(e) for e in res ]
  else:
    return Utils.typedobj_of_string( res )
开发者ID:bmb,项目名称:DIRAC,代码行数:7,代码来源:CS.py

示例4: typed_dict_of_dict

 def typed_dict_of_dict(d):
   for k in d:
     if type(d[k]) == dict:
       d[k] = typed_dict_of_dict(d[k])
     else:
       if d[k].find(",") > -1:
         d[k] = [Utils.typedobj_of_string(e) for e in List.fromChar(d[k])]
       else:
         d[k] = Utils.typedobj_of_string(d[k])
   return d
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:10,代码来源:CS.py

示例5: __getPolTypes

  def __getPolTypes(self, granularity, status=None, formerStatus=None, newStatus=None,
                    siteType=None, serviceType=None, resourceType=None):
    """Get Policy Types from config that match the given keyword
    arguments"""

    # This dict is constructed to be used with function dictMatch that
    # helps selecting policies. **kwargs are not used due to the fact
    # that it's too dangerous here.
    argsdict = {'Granularity': granularity,
                'Status': status,
                'FormerStatus': formerStatus,
                'NewStatus': newStatus,
                'SiteType': siteType,
                'ServiceType': serviceType,
                'ResourceType': resourceType}

    pTconfig = getTypedDictRootedAt("PolicyTypes")

    pTypes = []

    for pt in pTconfig:
      if Utils.dictMatch(argsdict, pTconfig[pt]):
        pTypes.append(pt)

    for pt_name in pTypes:
      if 'Alarm_PolType' in pt_name:
        pTypes.remove(pt_name)
        pTypes.append('Alarm_PolType')

    return pTypes
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:30,代码来源:InfoGetter.py

示例6: initializeResourceStatusHandler

def initializeResourceStatusHandler( _serviceInfo ):
  '''
    Handler initialization, where we set the ResourceStatusDB as global db, and
    we instantiate the synchronizer.
  '''
  global db
  db = ResourceStatusDB()

# Publisher is on boxes right now
#
#  rmDB = ResourceStatusDB()
#  cc = CommandCaller()
#  global VOExtension
#  VOExtension = getExt()
#  ig = InfoGetter( VOExtension )
#  WMSAdmin = RPCClient( "WorkloadStatus/WMSAdministrator" )
#  global publisher
#  publisher = Publisher( VOExtension, dbIn = db, commandCallerIn = cc,
#                         infoGetterIn = ig, WMSAdminIn = WMSAdmin )

  syncModule = Utils.voimport( 'DIRAC.ResourceStatusSystem.Utilities.Synchronizer' )
  syncObject = syncModule.Synchronizer()
  gConfig.addListenerToNewVersionEvent( syncObject.sync )
  
  return S_OK()
开发者ID:bmb,项目名称:DIRAC,代码行数:25,代码来源:ResourceStatusHandler.py

示例7: getValidStatusTypes

def getValidStatusTypes():
  '''
  Returns from the OperationsHelper: RSSConfiguration/GeneralConfig/Resources
  '''
  
  DEFAULTS = { 
               'Site'          : { 'StatusType' : "''" },
               'Service'       : { 'StatusType' : "''" },
               'Resource'      : { 'StatusType' : "''" },
               'StorageElement': { 'StatusType' : [ 'Read', 'Write', 'Remove', 'Check' ] }
              }
  
  opHelper = Operations()
  
  sections = opHelper.getSections( 'RSSConfiguration/GeneralConfig/Resources' )
  if not sections[ 'OK' ]:
    return DEFAULTS
  
  result = {}
  for section in sections[ 'Value' ]:
    res = opHelper.getValue( 'RSSConfiguration/GeneralConfig/Resources/%s/StatusType' % section )
    if res is None:
      if DEFAULTS.has_key( section ):
        result[ section ] = { 'StatusType' : DEFAULTS[ section ] }
      else:
        result[ section ] = { 'StatusType' : None }  
    else:
      result[ section ] = { 'StatusType' : Utils.getTypedList( res ) }
      
  return result     
开发者ID:bmb,项目名称:DIRAC,代码行数:30,代码来源:RssConfiguration.py

示例8: __getPanelsInfo

  def __getPanelsInfo( self, granularity, statusType = None, status = None,
                       formerStatus = None, siteType = None, serviceType = None,
                       resourceType = None, panel_name = None, useNewRes = False ):

    info = []

    # First, select only policies we want.
    argsdict = {'Granularity'  : granularity,
                'StatusType'   : statusType,
                'Status'       : status,
                'FormerStatus' : formerStatus,
                'SiteType'     : siteType,
                'ServiceType'  : serviceType,
                'ResourceType' : resourceType}


    all_policies = getTypedDictRootedAtOperations("Policies")
    selected_policies = []
    for p in all_policies:
      if Utils.dictMatch(argsdict, all_policies[p]):
        selected_policies.append(p)

    for p in selected_policies:                   # For selected policies
      if panel_name in self.C_Policies[p].keys(): # For selected panel_name (arguments)

        toAppend = copy.deepcopy(self.C_Policies[p][panel_name]) # type(toAppend) = list

        # Put CommandIn and args to correct values according to useNewRes
        if useNewRes:
          for panel in toAppend:
            for info_type in panel.keys():

              if type(panel[info_type]) == dict:
                try:
                  panel[info_type]['CommandIn'] = panel[info_type]['CommandInNewRes']
                  del panel[info_type]['CommandInNewRes']
                except KeyError:
                  pass
                try:
                  panel[info_type]['args'] = panel[info_type]['argsNewRes']
                  del panel[info_type]['argsNewRes']
                except KeyError:
                  pass
        else:
          for panel in toAppend:
            for info_type in panel.keys():
              try:
                del panel[info_type]['CommandInNewRes']
              except KeyError:
                pass
              try:
                del panel[info_type]['argsNewRes']
              except KeyError:
                pass

        info.append({p:toAppend})

    return info
开发者ID:bmb,项目名称:DIRAC,代码行数:58,代码来源:InfoGetter.py

示例9: __init__

  def __init__( self ):
    """c'tor

    :param self: self reference
    """

    self.log = gLogger.getSubLogger( 'ResourceStatusDB' )

    #These are the list of tables that will be created.
    #They can be extended in an extension module
    self.tablesList = getattr(Utils.voimport( 'DIRAC.ResourceStatusSystem.DB.ResourceStatusDB' ),
                              'TABLESLIST')
    self.tablesListWithID = getattr(Utils.voimport( 'DIRAC.ResourceStatusSystem.DB.ResourceStatusDB' ),
                                    'TABLESLISTWITHID')

    self.extensions = gConfig.getValue( 'DIRAC/Extensions', [] )
    self.__initializeConnection( 'ResourceStatus/ResourceStatusDB' )
    self.__initializeDB()
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:18,代码来源:ResourceStatusDB.py

示例10: policyInvocation

  def policyInvocation( self, granularity = None, name = None,
                        status = None, policy = None, args = None, pName = None,
                        pModule = None, extraArgs = None, commandIn = None ):
    '''
    Invokes a policy:

    1. If :attr:`policy` is None, import the policy module specified
    with :attr:`pModule` (e.g. 'DT_Policy').

      1.1. Create a policy object.

    2. Set the policy arguments (usually :attr:`granularity`,
    :attr:`name`) + :attr:`extraArgs`.

    3. If commandIn is specified (normally it is), use
    :meth:`DIRAC.ResourceStatusSystem.Command.CommandCaller.CommandCaller.setCommandObject`
    to get a command object
    '''

    if not policy:

      try:
      
        policyModule = Utils.voimport( 'DIRAC.ResourceStatusSystem.Policy.%s' % pModule )
        
      except ImportError:
        _msg = 'Unable to import a policy module named %s, falling back on AlwaysFalse_Policy.' % pModule
        gLogger.warn( _msg )
        policyModule = __import__( 'DIRAC.ResourceStatusSystem.Policy.AlwaysFalse_Policy',
                                   globals(), locals(), ['*'] )
        pModule = 'AlwaysFalse_Policy'
        
      try:
        
        policy = getattr( policyModule, pModule )()
        
      except AttributeError as exc:
        print policyModule, pModule
        raise exc

    if not args:
      args = ( granularity, name )

    if extraArgs:
      args = args + tuple( extraArgs )

    if commandIn:
      commandIn = self.cCaller.setCommandObject( commandIn )
      for clientName, clientInstance in self.clients.items():
        
        self.cCaller.setAPI( commandIn, clientName, clientInstance )

    res = self._innerEval( policy, args, commandIn = commandIn )
    # Just adding the PolicyName to the result of the evaluation of the policy
    res[ 'PolicyName' ] = pName
    return res
开发者ID:bmb,项目名称:DIRAC,代码行数:56,代码来源:PolicyCaller.py

示例11: __init__

  def __init__(self, VOExtension):
    """
    Standard constructor

    :params:
      :attr:`VOExtension`: string - VO extension (e.g. 'LHCb')
    """

    configModule    = Utils.voimport("DIRAC.ResourceStatusSystem.Policy.Configurations", VOExtension)
    self.C_Policies = copy.deepcopy(configModule.Policies)
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:10,代码来源:InfoGetter.py

示例12: __init__

  def __init__(self, VOExtension, rsDBIn = None, commandCallerIn = None, infoGetterIn = None,
               WMSAdminIn = None):
    """
    Standard constructor

    :params:
      :attr:`VOExtension`: string, VO Extension (e.g. 'LHCb')

      :attr:`rsDBIn`: optional ResourceStatusDB object
      (see :class: `DIRAC.ResourceStatusSystem.DB.ResourceStatusDB.ResourceStatusDB`)

      :attr:`commandCallerIn`: optional CommandCaller object
      (see :class: `DIRAC.ResourceStatusSystem.Command.CommandCaller.CommandCaller`)

      :attr:`infoGetterIn`: optional InfoGetter object
      (see :class: `DIRAC.ResourceStatusSystem.Utilities.InfoGetter.InfoGetter`)

      :attr:`WMSAdminIn`: optional RPCClient object for WMSAdmin
      (see :class: `DIRAC.Core.DISET.RPCClient.RPCClient`)
    """

    self.configModule = Utils.voimport("DIRAC.ResourceStatusSystem.Policy.Configurations", VOExtension)

    if rsDBIn is not None:
      self.rsDB = rsDBIn
    else:
      from DIRAC.ResourceStatusSystem.DB.ResourceStatusDB import ResourceStatusDB
      self.rsDB = ResourceStatusDB()

    from DIRAC.ResourceStatusSystem.DB.ResourceManagementDB import ResourceManagementDB
    self.rmDB = ResourceManagementDB()

    if commandCallerIn is not None:
      self.cc = commandCallerIn
    else:
      from DIRAC.ResourceStatusSystem.Command.CommandCaller import CommandCaller
      self.cc = CommandCaller()

    if infoGetterIn is not None:
      self.ig = infoGetterIn
    else:
      from DIRAC.ResourceStatusSystem.Utilities.InfoGetter import InfoGetter
      self.ig = InfoGetter(VOExtension)

    if WMSAdminIn is not None:
      self.WMSAdmin = WMSAdminIn
    else:
      from DIRAC.Core.DISET.RPCClient import RPCClient
      self.WMSAdmin = RPCClient("WorkloadManagement/WMSAdministrator")

    self.threadPool = ThreadPool( 2, 5 )

    self.lockObj = threading.RLock()

    self.infoForPanel_res = {}
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:55,代码来源:Publisher.py

示例13: getValidPolicyTypes

def getValidPolicyTypes():
  '''
  Returns from the OperationsHelper: RSSConfiguration/GeneralConfig/PolicyTypes
  '''
  
  DEFAULTS = [ 'Resource_PolType', 'Alarm_PolType', 'Collective_PolType', 'RealBan_PolType' ]
  
  result = Operations().getValue( 'RSSConfiguration/GeneralConfig/PolicyTypes' )
  if result is not None:
    return Utils.getTypedList( result )
  return DEFAULTS
开发者ID:bmb,项目名称:DIRAC,代码行数:11,代码来源:RssConfiguration.py

示例14: __init__

 def __init__( self ):
   """ Constructor. Imports the policy configurations containing the command
   information, among other things. 
   
   examples:
     >>> iGetter = InfoGetter()
   
   """
       
   configModule  = Utils.voimport( 'DIRAC.ResourceStatusSystem.Policy.Configurations' )
   self.policies = copy.deepcopy( configModule.POLICIESMETA )  
开发者ID:graciani,项目名称:DIRAC,代码行数:11,代码来源:InfoGetter.py

示例15: getValidElements

def getValidElements():
  '''
  Returns from the OperationsHelper: RSSConfiguration/GeneralConfig/Granularity
  '''
  
  DEFAULTS = [ 'Site', 'Service', 'Resource', 'StorageElement' ]
  
  result = Operations().getValue( 'RSSConfiguration/GeneralConfig/Granularity' )
  if result is not None:
    return Utils.getTypedList( result )
  return DEFAULTS
开发者ID:bmb,项目名称:DIRAC,代码行数:11,代码来源:RssConfiguration.py


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