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


Python BasicAlgos.findMagicStr方法代码示例

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


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

示例1: complete

# 需要导入模块: from WMCore.Algorithms import BasicAlgos [as 别名]
# 或者: from WMCore.Algorithms.BasicAlgos import findMagicStr [as 别名]
    def complete(self, jobs):
        """
        Do any completion work required

        In this case, look for a returned logfile
        """

        for job in jobs:

            if job.get('cache_dir', None) is None or job.get('retry_count', None) is None:
                # Then we can't do anything
                logging.error("Can't find this job's cache_dir or retry count: %s", job)
                continue

            reportName = os.path.join(job['cache_dir'], 'Report.%i.pkl' % job['retry_count'])
            if os.path.isfile(reportName) and os.path.getsize(reportName) > 0:
                # everything in order, move on
                continue
            elif os.path.isdir(reportName):
                # Then something weird has happened. Report error, do nothing
                logging.error("The job report for job with id %s and gridid %s is a directory", job['id'],
                              job['gridid'])
                logging.error("Ignoring this, but this is very strange")
            else:
                logging.error("No job report for job with id %s and gridid %s", job['id'], job['gridid'])

                if os.path.isfile(reportName):
                    os.remove(reportName)

                # create a report from scratch
                condorReport = Report()
                logOutput = 'Could not find jobReport\n'

                if os.path.isdir(job['cache_dir']):
                    condorOut = "condor.%s.out" % job['gridid']
                    condorErr = "condor.%s.err" % job['gridid']
                    condorLog = "condor.%s.log" % job['gridid']
                    exitCode = 99303
                    exitType = "NoJobReport"
                    for condorFile in [condorOut, condorErr, condorLog]:
                        condorFilePath = os.path.join(job['cache_dir'], condorFile)
                        if os.path.isfile(condorFilePath):
                            logTail = BasicAlgos.tail(condorFilePath, 50)
                            logOutput += 'Adding end of %s to error message:\n\n' % condorFile
                            logOutput += logTail
                            logOutput += '\n\n'
                            for exMsg in listWMExceptionStr(condorFilePath):
                                logOutput += "\n\n%s\n" % exMsg

                            if condorFile == condorLog:
                                for condorReason in BasicAlgos.findMagicStr(condorFilePath, '<a n="Reason">'):
                                    logOutput += condorReason
                                    if "SYSTEM_PERIODIC_REMOVE" in condorReason or "via condor_rm" in condorReason:
                                        exitCode = 99400
                                        exitType = "RemovedByGLIDEIN"
                                    else:
                                        exitCode = 99401
                    logOutput += '\n\n'
                    condorReport.addError(exitType, exitCode, exitType, logOutput)
                else:
                    msg = "Serious Error in Completing condor job with id %s!\n" % job['id']
                    msg += "Could not find jobCache directory %s\n" % job['cache_dir']
                    msg += "Creating a new cache_dir for failed job report\n"
                    logging.error(msg)
                    os.makedirs(job['cache_dir'])
                    condorReport.addError("NoJobReport", 99304, "NoCacheDir", logOutput)

                condorReport.save(filename=reportName)

                logging.debug("Created failed job report for job with id %s and gridid %s", job['id'], job['gridid'])

        return
开发者ID:alexanderrichards,项目名称:WMCore,代码行数:74,代码来源:SimpleCondorPlugin.py


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