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


Python ResourceStatusClient.getGridSiteName方法代码示例

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


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

示例1: doCommand

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getGridSiteName [as 别名]
  def doCommand(self, rsClientIn=None):
    """ 
    Return getStatus from SAM Results Client  
    
   :attr:`args`: 
     - args[0]: string: should be a ValidRes

     - args[1]: string: should be the (DIRAC) name of the ValidRes
     
     - args[2]: string: optional - should be the (DIRAC) site name of the ValidRes
     
     - args[3]: list: list of tests
    """
    super(SAMResults_Command, self).doCommand()
    
    if self.client is None:
      from DIRAC.Core.LCG.SAMResultsClient import SAMResultsClient
      self.client = SAMResultsClient()

    if rsClientIn is not None:
      rsc = rsClientIn
    else:
      # use standard RS Client
      from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient
      rsc = ResourceStatusClient()

    granularity = self.args[0]
    name = self.args[1]
    try:  
      siteName = self.args[2]
    except IndexError:
      siteName = None

    if granularity in ('Site', 'Sites'):
      siteName = getGOCSiteName(name)
      if not siteName['OK']:
        raise RSSException, siteName['Message']
      siteName = siteName['Value']
    elif granularity in ('Resource', 'Resources'):
      if siteName is None:
        siteName = rsc.getGridSiteName(granularity, name)
      else:
        siteName = getGOCSiteName(siteName)
        if not siteName['OK']:
          raise RSSException, siteName['Message']
        siteName = siteName['Value']
    else:
      raise InvalidRes, where(self, self.doCommand)
    
    try:  
      tests = self.args[3]
    except IndexError:
      tests = None
    finally:
      try:
        
        res = self.client.getStatus(granularity, name, siteName, tests, 
                                    timeout = self.timeout)
        if not res['OK']:
          gLogger.error("There are no SAM tests for " + granularity + " " + name )
          return  {'Result':None}
      except urllib2.URLError:
        gLogger.error("SAM timed out for " + granularity + " " + name )
        return  {'Result':'Unknown'}      
      except httplib.BadStatusLine:
        gLogger.error("httplib.BadStatusLine: could not read" + granularity + " " + name )
        return  {'Result':'Unknown'}
      except:
        gLogger.exception("Exception when calling SAMResultsClient for %s %s" %(granularity, name))
        return  {'Result':'Unknown'}

    return {'Result':res['Value']}
开发者ID:KrzysztofCiba,项目名称:DIRAC,代码行数:74,代码来源:SAMResults_Command.py


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