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


Python ResourceManagementClient.selectGGUSTicketsCache方法代码示例

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


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

示例1: GGUSTicketsCommand

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import selectGGUSTicketsCache [as 别名]

#.........这里部分代码省略.........
    if masterParams is not None:
      gocName = masterParams
      gocNames = [gocName]

    else:
      gocName = self._prepareCommand()
      if not gocName['OK']:
        return gocName
      gocName = gocName['Value']
      gocNames = [gocName]

    try:
      results = self.gClient.getTicketsList(gocName)
    except urllib2.URLError as e:
      return S_ERROR('%s %s' % (gocName, e))

    if not results['OK']:
      return results
    results = results['Value']

    uniformResult = []

    for gocSite, ggusResult in results.items():

      if gocSite not in gocNames:
        continue

      ggusDict = {}
      ggusDict['GocSite'] = gocSite
      ggusDict['Link'] = ggusResult['URL']

      del ggusResult['URL']

      openTickets = 0
      for priorityDict in ggusResult.values():
        openTickets += len(priorityDict)

      ggusDict['Tickets'] = ggusResult
      ggusDict['OpenTickets'] = openTickets

      uniformResult.append(ggusDict)

    storeRes = self._storeCommand(uniformResult)
    if not storeRes['OK']:
      return storeRes

    return S_OK(uniformResult)

  def doCache(self):
    '''
      Method that reads the cache table and tries to read from it. It will
      return a list of dictionaries if there are results.
    '''

    gocName = self._prepareCommand()
    if not gocName['OK']:
      return gocName
    gocName = gocName['Value']

    result = self.rmClient.selectGGUSTicketsCache(gocSite=gocName)
    if result['OK']:
      result = S_OK([dict(zip(result['Columns'], res)) for res in result['Value']])

    return result

  def doMaster(self):
    '''
      Master method, which looks little bit spaguetti code, sorry !
      - It gets all gocSites.

      As there is no bulk query, it compares with what we have on the database.
      It queries a portion of them.
    '''

    gocSites = CSHelpers.getGOCSites()
    if not gocSites['OK']:
      return gocSites
    gocSites = gocSites['Value']

#    resQuery = self.rmClient.selectGGUSTicketsCache( meta = { 'columns' : [ 'GocSite' ] } )
#    if not resQuery[ 'OK' ]:
#      return resQuery
#    resQuery = [ element[0] for element in resQuery[ 'Value' ] ]
#
#    gocNamesToQuery = set( gocSites ).difference( set( resQuery ) )

    self.log.info('Processing %s' % ', '.join(gocSites))

    for gocNameToQuery in gocSites:

      #    if gocNameToQuery is None:
      #      self.metrics[ 'failed' ].append( 'None result' )
      #      continue

      result = self.doNew(gocNameToQuery)

      if not result['OK']:
        self.metrics['failed'].append(result)

    return S_OK(self.metrics)
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:104,代码来源:GGUSTicketsCommand.py


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