utils.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:ISB-CGC-pipelines 作者: isb-cgc 项目源码 文件源码
def getJobLogs(args, config):  # TODO: reimplement
        pipelineDbUtils = PipelineDbUtils(config)

        jobInfo = pipelineDbUtils.getJobInfo(select=["stdout_log", "stderr_log", "gcs_log_path"],
                                             where={"job_id": args.jobId})

        with open(os.devnull, 'w') as fnull:
            if args.stdout:
                try:
                    stdoutLogFile = subprocess.check_output(
                        ["gsutil", "cat", os.path.join(jobInfo[0].gcs_log_path, jobInfo[0].stdout_log)], stderr=fnull)
                except subprocess.CalledProcessError as e:
                    print "ERROR: couldn't get the stdout log : {reason}".format(reason=e)
                    exit(-1)

                print "STDOUT:\n"
                print stdoutLogFile
                print "---------\n"

            if args.stderr:
                try:
                    stderrLogFile = subprocess.check_output(
                        ["gsutil", "-q", "cat", os.path.join(jobInfo[0].gcs_log_path, jobInfo[0].stderr_log)],
                        stderr=fnull)
                except subprocess.CalledProcessError as e:
                    print "ERROR: couldn't get the stderr log : {reason}".format(reason=e)
                    exit(-1)

                print "STDERR:\n"
                print stderrLogFile
                print "---------\n"

        pipelineDbUtils.closeConnection()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号