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


Python Job.from_id方法代码示例

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


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

示例1: kill_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def kill_job(request, jobid):
  """
  We get here from /jobs/jobid/kill
  """
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s)") % dict(method=request.method))
  job = Job.from_id(jt=request.jt, jobid=jobid)
  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, _('Insufficient permission'))
    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") %
                           dict(username=request.user.username, user=job.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=jobid)

    if job.status not in ["RUNNING", "QUEUED"]:
      if request.REQUEST.get("next"):
        return HttpResponseRedirect(request.REQUEST.get("next"))
      else:
        raise MessageException("Job Killed")
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=jobid)

  raise Exception(_("Job did not appear as killed within 15 seconds"))
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:28,代码来源:views.py

示例2: kill_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def kill_job(request, job):
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s).") % dict(method=request.method))

  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, _('Insufficient permission'))
    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") %
                           dict(username=request.user.username, user=job.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=job.jobId)

    if job.status not in ["RUNNING", "QUEUED"]:
      if request.REQUEST.get("next"):
        return HttpResponseRedirect(request.REQUEST.get("next"))
      elif request.REQUEST.get("format") == "json":
        return HttpResponse(encode_json_for_js({'status': 0}), mimetype="application/json")
      else:
        raise MessageException("Job Killed")
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=job.jobId)

  raise Exception(_("Job did not appear as killed within 15 seconds."))
开发者ID:chiehwen,项目名称:hue,代码行数:27,代码来源:views.py

示例3: job_single_logs

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def job_single_logs(request, jobid):
  """
  We get here from /jobs/jobid/logs
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)

  def cmp_exec_time(task1, task2):
    return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

  task = None

  failed_tasks = job.filter_tasks(task_states=('failed',))
  failed_tasks.sort(cmp_exec_time)
  if failed_tasks:
    task = failed_tasks[0]
  else:
    recent_tasks = job.filter_tasks(task_states=('running', 'succeeded',), task_types=('map', 'reduce',))
    recent_tasks.sort(cmp_exec_time, reverse=True)
    if recent_tasks:
      task = recent_tasks[0]

  if task is None:
    raise PopupException(_("No tasks found for job %(id)s") % dict(id=jobid))

  return single_task_attempt_logs(request, **{'jobid': jobid, 'taskid': task.taskId, 'attemptid': task.taskAttemptIds[-1]})
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:27,代码来源:views.py

示例4: decorate

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
 def decorate(request, *args, **kwargs):
   jobid = kwargs['jobid']
   job = Job.from_id(jt=request.jt, jobid=jobid)
   if not conf.SHARE_JOBS.get() and not request.user.is_superuser \
     and job.user != request.user.username:
     raise PopupException(_("You don't have the permissions to access"
                            " job %(id)s") % dict(id=jobid))
   return view_func(request, *args, **kwargs)
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:10,代码来源:views.py

示例5: kill_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def kill_job(request, jobid):
  """
  We get here from /jobs/jobid/kill
  """
  if request.method != "POST":
    raise Exception("kill_job may only be invoked with a POST (got a %s)" % request.method)
  job = Job.from_id(jt=request.jt, jobid=jobid)
  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, 'Insufficient permission')
    raise MessageException("Permission denied.  User %s cannot delete user %s's job." %
                           (request.user.username, job.profile.user))

  job.kill()
  cur_time = time.time()
  while time.time() - cur_time < 15:
    job = Job.from_id(jt=request.jt, jobid=jobid)

    if job.status not in ["RUNNING", "QUEUED"]:
      return render_json({})
    time.sleep(1)
    job = Job.from_id(jt=request.jt, jobid=jobid)

  raise Exception("Job did not appear as killed within 15 seconds")
开发者ID:anutron,项目名称:hue,代码行数:25,代码来源:views.py

示例6: single_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def single_job(request, jobid):
    """
  We get here from /jobs/jobid
  """
    job = Job.from_id(jt=request.jt, jobid=jobid)

    def cmp_exec_time(task1, task2):
        return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

    failed_tasks = job.filter_tasks(task_states=("failed",))
    failed_tasks.sort(cmp_exec_time)
    recent_tasks = job.filter_tasks(task_states=("running", "succeeded"))
    recent_tasks.sort(cmp_exec_time, reverse=True)

    return render(
        "job.mako",
        request,
        {"request": request, "job": job, "failed_tasks": failed_tasks[:5], "recent_tasks": recent_tasks[:5]},
    )
开发者ID:shreepadma,项目名称:hue,代码行数:21,代码来源:views.py

示例7: single_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def single_job(request, jobid):
  """
  We get here from /jobs/jobid
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)

  def cmp_exec_time(task1, task2):
    return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

  failed_tasks = job.filter_tasks(task_states=('failed',))
  failed_tasks.sort(cmp_exec_time)
  recent_tasks = job.filter_tasks(task_states=('running', 'succeeded',))
  recent_tasks.sort(cmp_exec_time, reverse=True)

  return render("job.mako", request, {
    'request': request,
    'job': job,
    'failed_tasks': failed_tasks[:5],
    'recent_tasks': recent_tasks[:5]
  })
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:22,代码来源:views.py

示例8: get_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
 def get_job(self, jobid):
   return Job.from_id(jt=self.jt, jobid=jobid)
开发者ID:Andrea1988,项目名称:hue,代码行数:4,代码来源:api.py

示例9: job_counters

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def job_counters(request, jobid):
  """
  We get here from /jobs/jobid/counters
  """
  job = Job.from_id(jt=request.jt, jobid=jobid)
  return render("counters.html", request, {"counters":job.counters})
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:8,代码来源:views.py

示例10: get_single_job

# 需要导入模块: from jobbrowser.models import Job [as 别名]
# 或者: from jobbrowser.models.Job import from_id [as 别名]
def get_single_job(request, jobid):
  """
  Returns the job which matches jobid.
  """
  return Job.from_id(jt=request.jt, jobid=jobid)
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:7,代码来源:views.py


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