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


Python Dirac.kill方法代码示例

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


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

示例1: CEBaseTest

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import kill [as 别名]

#.........这里部分代码省略.........
      os.environ[ 'X509_USER_PROXY' ] = oldProxy
    LOCK.release()

    return result


  def getTestResult( self, elementName, vo, jobID, submissionTime ):
    """
      download output sandbox and judge the test status from the log file.
    """

    isFinish = False

    res = self.__getJobOutput( jobID, vo )
    if not res[ 'OK' ]:
      return res
    output = res[ 'Value' ]
    status = res[ 'Status' ]

    resDict = { 'CompletionTime' : None, 'Status' : None, 'Log' : None, 'ApplicationTime' : None }
    utcNow = datetime.utcnow().replace( microsecond = 0 )

    if output:
      isFinish = True
      resDict[ 'CompletionTime' ] = utcNow
      log = output[ 'Log' ]
      if not output[ 'Download' ]:
        resDict[ 'Status' ] = 'Unknown'
        resDict[ 'Log' ] = 'Fail to download log file for job %s: %s' % ( jobID, log )
      else:
        resDict[ 'Log' ] = log
        resDict[ 'Status' ] = self._judge( log )
        resDict[ 'AppliactionTime' ] = self.__getAppRunningTime( log )

    else:
      if utcNow - submissionTime >= timedelta( seconds = self.timeout ):
        isFinish = True
        if elementName.split( '.' )[ 0 ] == 'CLOUD':
          site = elementName
        else:
          site = BESUtils.getSiteForCE( elementName )
        jobCount = self.wmsAdmin.getSiteSummaryWeb( { 'Site' : site }, [], 0, 0 )
        if not jobCount[ 'OK' ]:
          return jobCount
        params = jobCount[ 'Value' ][ 'ParameterNames' ]
        records = jobCount[ 'Value' ][ 'Records' ][ 0 ]
        run = records[ params.index( 'Running' ) ]
        done = records[ params.index( 'Done' ) ]
        if status == 'Waiting' and run == 0 and done == 0:
          resDict[ 'Status' ] = 'Bad'
          resDict[ 'Log' ] = 'The test job is waiting for %d seconds, but no running and done jobs at this site.' % self.timeout
        else:
          if run != 0:
            resDict[ 'Status' ] = 'Busy'
            resDict[ 'Log' ] = 'Site %s is too busy to execute this test job, job status is %s' % ( site, status )
          else:
            resDict[ 'Status' ] = 'Unknown'
            resDict[ 'Log' ] = 'Test did not complete within the timeout of %d seconds, job status is %s' % ( self.timeout, status )
        self.dirac.kill( jobID )

    if not isFinish:
      return S_OK()
    else:
      return S_OK( resDict )


  def __getJobOutput( self, jobID, vo ):
    status = self.dirac.status( jobID )
    if not status[ 'OK' ]:
      return status
    status = status[ 'Value' ][ jobID ][ 'Status' ]

    if status in ( 'Done', 'Failed' ):
      LOCK.acquire()
      proxyPath = BESUtils.getProxyByVO( 'zhangxm', vo )
      if not proxyPath[ 'OK' ]:
        LOCK.release()
        return proxyPath
      proxyPath = proxyPath[ 'Value' ]
      oldProxy = os.environ.get( 'X509_USER_PROXY' )
      os.environ[ 'X509_USER_PROXY' ] = proxyPath
      outputRes = self.dirac.getOutputSandbox( jobID, self.__logPath )
      if oldProxy is None:
        del os.environ[ 'X509_USER_PROXY' ]
      else:
        os.environ[ 'X509_USER_PROXY' ] = oldProxy
      LOCK.release()

      if not outputRes[ 'OK' ]:
        ret = S_OK( { 'Download'  : False, 'Log' : outputRes[ 'Message' ] } )
      else:
        try:
          logfile = open( '%s/%d/Script1_CodeOutput.log' % ( self.__logPath, jobID ), 'r' )
          log = logfile.read()
          logfile.close()
        except IOError, e:
          raise IOError
        os.system( 'rm -rf %s/%d' % ( self.__logPath, jobID ) )
        ret = S_OK( { 'Download' : True, 'Log' : log } )
    else:
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:104,代码来源:CEBaseTest.py

示例2: Operations

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import kill [as 别名]
    from DIRAC.Interfaces.API.Dirac import Dirac
    from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
    from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
    
    # get necessary credentials
    op = Operations("glast.org")
    shifter = op.getValue("Pipeline/Shifter","/DC=org/DC=doegrids/OU=People/CN=Stephan Zimmer 799865")
    shifter_group = op.getValue("Pipeline/ShifterGroup","glast_user")
    result = gProxyManager.downloadProxyToFile(shifter,shifter_group,requiredTimeLeft=10000)
    if not result['OK']:
        gLogger.error("ERROR: No valid proxy found; ",result['Message'])
        dexit(1)
    proxy = result[ 'Value' ]
    environ['X509_USER_PROXY'] = proxy
    gLogger.info("using proxy %s"%proxy)
    dirac = Dirac(True,"myRepo.rep")
    exitCode = 0
    errorList = []
    if len( args ) < 1:
        Script.showHelp()
    for job in args:
        result = dirac.kill( job )
        if result['OK']:
            gLogger.info('Killed job %s' % ( job ))
        else:
            errorList.append( ( job, result['Message'] ) )
            exitCode = 2
    for error in errorList:
        gLogger.error("ERROR %s: %s" % error)
    dexit.exit( exitCode )
开发者ID:Glast,项目名称:GlastDIRAC,代码行数:32,代码来源:dirac-glast-pipeline-kill.py

示例3: LoggingRecord

# 需要导入模块: from DIRAC.Interfaces.API.Dirac import Dirac [as 别名]
# 或者: from DIRAC.Interfaces.API.Dirac.Dirac import kill [as 别名]
            for l in logs:
                logging_obj.append( LoggingRecord(l) )
            logging_info = {'Submitted': logging_obj[0].time, 'Started': None, 'Ended': None, 'JobID': str(job)}
            for record in logging_obj:
                if record.major_status == 'Application':
                    logging_info['Started'] = record.time
            if status_j['Status'] == 'Done':
                logging_info['Ended']=logging_obj[-1].time 
            status_j.update(logging_info)
        new_stat = InternalJobStatus(job,status_j)
        sys.stdout = stdout
        if new_stat.getStatus()=="Failed":
            if not new_stat.getEndTime():
                gLogger.info("Time stamp for ended job %i not provided, setting it to 1 day in the past!" %job)
                new_stat.setEndTime()
                gLogger.info("Requesting to kill job %i" %job)
                d.kill(job)
        if job in sites:
            new_stat.setSite(sites[job]['Site'])
        #print new_stat._toxml().toprettyxml()
        if do_xml:
            firstChild.appendChild(new_stat._toxml())
        else:
            print(new_stat)
    # TODO:
        # pretty print & parse in java
    sys.stdout = stdout
    if do_xml:
        print(xmlfile.toprettyxml())

开发者ID:brianv0,项目名称:GlastDIRAC,代码行数:31,代码来源:dirac-glast-pipeline-status.py


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