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


Python Time.fromEpoch方法代码示例

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


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

示例1: export_setJobStatusBulk

# 需要导入模块: from DIRAC import Time [as 别名]
# 或者: from DIRAC.Time import fromEpoch [as 别名]
  def export_setJobStatusBulk( self, jobID, statusDict ):
    """ Set various status fields for job specified by its JobId.
        Set only the last status in the JobDB, updating all the status
        logging information in the JobLoggingDB. The statusDict has datetime
        as a key and status information dictionary as values
    """

    status = ""
    minor = ""
    application = ""
    appCounter = ""
    endDate = ''
    startDate = ''
    startFlag = ''
    jobID = int( jobID )

    result = jobDB.getJobAttributes( jobID, ['Status'] )
    if not result['OK']:
      return result

    if not result['Value']:
      # if there is no matching Job it returns an empty dictionary
      return S_ERROR( 'No Matching Job' )

    new_status = result['Value']['Status']
    if new_status == "Stalled":
      status = 'Running'

    # Get the latest WN time stamps of status updates
    result = logDB.getWMSTimeStamps( int( jobID ) )
    if not result['OK']:
      return result
    lastTime = max( [float( t ) for s, t in result['Value'].items() if s != 'LastTime'] )
    from DIRAC import Time
    lastTime = Time.toString( Time.fromEpoch( lastTime ) )

    # Get the last status values
    dates = sorted( statusDict )
    # We should only update the status if its time stamp is more recent than the last update
    for date in [date for date in dates if date >= lastTime]:
      sDict = statusDict[date]
      if sDict['Status']:
        status = sDict['Status']
        if status in JOB_FINAL_STATES:
          endDate = date
        if status == "Running":
          startFlag = 'Running'
      if sDict['MinorStatus']:
        minor = sDict['MinorStatus']
        if minor == "Application" and startFlag == 'Running':
          startDate = date
      if sDict['ApplicationStatus']:
        application = sDict['ApplicationStatus']
      counter = sDict.get( 'ApplicationCounter' )
      if counter:
        appCounter = counter
    attrNames = []
    attrValues = []
    if status:
      attrNames.append( 'Status' )
      attrValues.append( status )
    if minor:
      attrNames.append( 'MinorStatus' )
      attrValues.append( minor )
    if application:
      attrNames.append( 'ApplicationStatus' )
      attrValues.append( application )
    if appCounter:
      attrNames.append( 'ApplicationCounter' )
      attrValues.append( appCounter )
    result = jobDB.setJobAttributes( jobID, attrNames, attrValues, update = True )
    if not result['OK']:
      return result

    if endDate:
      result = jobDB.setEndExecTime( jobID, endDate )
    if startDate:
      result = jobDB.setStartExecTime( jobID, startDate )

    # Update the JobLoggingDB records
    for date in dates:
      sDict = statusDict[date]
      status = sDict['Status']
      if not status:
        status = 'idem'
      minor = sDict['MinorStatus']
      if not minor:
        minor = 'idem'
      application = sDict['ApplicationStatus']
      if not application:
        application = 'idem'
      else:
        status = "Running"
        minor = "Application"
      source = sDict['Source']
      result = logDB.addLoggingRecord( jobID, status, minor, application, date, source )
      if not result['OK']:
        return result

    return S_OK()
开发者ID:alexanderrichards,项目名称:DIRAC,代码行数:102,代码来源:JobStateUpdateHandler.py


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