本文整理汇总了Python中bkr.server.model.Task.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Task.by_id方法的具体用法?Python Task.by_id怎么用?Python Task.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Task
的用法示例。
在下文中一共展示了Task.by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: default
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_id [as 别名]
def default(self, *args, **kw):
try:
using_task_id = False
if len(args) == 1:
try:
task_id = int(args[0])
using_task_id = True
except ValueError:
pass
if using_task_id:
task = Task.by_id(task_id)
else:
task = Task.by_name("/%s" % "/".join(args))
#Would rather not redirect but do_search expects task_id in URL
#This is the simplest way of dealing with it
redirect("/tasks/%s" % task.id)
except DatabaseLookupError as e:
flash(unicode(e))
redirect("/tasks")
return dict(task=task,
form = self.task_form,
value = dict(task_id = task.id),
options = dict(hidden=dict(task = 1)),
action = './do_search')
示例2: default
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_id [as 别名]
def default(self, *args, **kw):
try:
using_task_id = False
if len(args) == 1:
try:
task_id = int(args[0])
using_task_id = True
except ValueError:
pass
if using_task_id:
task = Task.by_id(task_id)
else:
task = Task.by_name("/%s" % "/".join(args))
#Would rather not redirect but do_search expects task_id in URL
#This is the simplest way of dealing with it
redirect("/tasks/%s" % task.id)
except InvalidRequestError:
if using_task_id:
err_msg = u'Invalid task_id %s' % args[0]
else:
err_msg = u'Invalid task /%s' % '/'.join(args)
flash(_(err_msg))
redirect("/tasks")
return dict(task=task,
form = self.task_form,
value = dict(task_id = task.id),
options = dict(hidden=dict(task = 1)),
action = './do_search')
示例3: _disable
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_id [as 别名]
def _disable(self, t_id, *args, **kw):
"""
disable task
task.valid=False
remove task rpms from filesystem
"""
task = Task.by_id(t_id)
return task.disable()