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


Python Job.get方法代码示例

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


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

示例1: job_log

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import get [as 别名]
def job_log(uid, logtype, page):
    logtype = logtype.upper()
    if not logtype or (logtype != "STDOUT" and logtype != "STDERR"):
        raise StandardError("Invalid log type, expected either 'stdout' or 'stderr'")
    if not page:
        raise StandardError("Unrecognized page number '%s'" % page)
    # Fetch job for uid
    job = Job.get(db.session, uid)
    if not job:
        raise StandardError("No job for id '%s'" % uid)
    # Looking up file and creating output
    suffix = jobscheduler.STDOUT if logtype == "STDOUT" else jobscheduler.STDERR
    path = os.path.join(jobscheduler.jobWorkingDirectory(uid), suffix)
    if not os.path.isfile(path):
        raise StandardError("No logs found for job id '%s'" % uid)
    block, numPages = "", -1
    chunk, offset = 64*1024, 128
    manager = BlockReader()
    with open(path, "rb") as f:
        numPages = manager.numPages(f, chunk)
        block = manager.readFromStart(f, page, chunk, offset)
    # Current page API url
    current_page_url = api("/job/log/%s/%s/page/%s" % (job.uid, logtype, page))
    # Next page API url
    next_page_url = api("/job/log/%s/%s/page/%s" % (job.uid, logtype, page + 1)) \
        if page < numPages else None
    # Previous page API url
    prev_page_url = api("/job/log/%s/%s/page/%s" % (job.uid, logtype, page - 1)) \
        if page > 1 else None
    last_page_url = api("/job/log/%s/%s/page/%s" % (job.uid, logtype, numPages)) \
        if numPages > 1 else None
    # Jump-to-page url
    jump_to_page_url = api("/job/log/%s/%s/page/_page_" % (job.uid, logtype))
    return success({"uid": job.uid, "name": job.name, "type": logtype, "pages": numPages,
        "page": page, "block": block, "size": chunk, "next_page_url": next_page_url,
        "prev_page_url": prev_page_url, "current_page_url": current_page_url,
        "jump_to_page_url": jump_to_page_url, "last_page_url": last_page_url})
开发者ID:sadikovi,项目名称:octohaven,代码行数:39,代码来源:octohaven.py

示例2: job_close

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import get [as 别名]
def job_close(uid):
    job = Job.get(db.session, uid)
    if not job:
        raise StandardError("No job for id '%s'" % uid)
    Job.close(db.session, job)
    return success(job.json())
开发者ID:sadikovi,项目名称:octohaven,代码行数:8,代码来源:octohaven.py

示例3: job_for_uid

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import get [as 别名]
def job_for_uid(uid):
    job = Job.get(db.session, uid)
    dump = json.dumps(job.json()) if job else ""
    return render_page("job.html", job=dump)
开发者ID:sadikovi,项目名称:octohaven,代码行数:6,代码来源:octohaven.py

示例4: job_stdlogs

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import get [as 别名]
def job_stdlogs(uid):
    job = Job.get(db.session, uid)
    dump = json.dumps(job.json()) if job else ""
    jobName = job.name if job else ""
    title = request.path.upper().split("/")[-1]
    return render_page("job_console.html", title=title, uid=uid, name=jobName, job=dump)
开发者ID:sadikovi,项目名称:octohaven,代码行数:8,代码来源:octohaven.py

示例5: create_timetable_job

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import get [as 别名]
def create_timetable_job(uid):
    job = Job.get(db.session, uid)
    dump = json.dumps(job.json()) if job else ""
    return render_page("create_timetable.html", job=dump)
开发者ID:sadikovi,项目名称:octohaven,代码行数:6,代码来源:octohaven.py


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