本文整理汇总了Python中bkr.server.model.Task.update_task方法的典型用法代码示例。如果您正苦于以下问题:Python Task.update_task方法的具体用法?Python Task.update_task怎么用?Python Task.update_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Task
的用法示例。
在下文中一共展示了Task.update_task方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import update_task [as 别名]
def save(self, task_rpm, *args, **kw):
"""
TurboGears method to upload task rpm package
"""
rpm_path = Task.get_rpm_path(task_rpm.filename)
if not task_rpm.filename:
flash(_(u'No task RPM specified'))
redirect(url("./new"))
# we do it here, since we do not want to proceed
# any further
if len(task_rpm.filename) > 255:
flash(_(u"Task RPM name should be <= 255 characters"))
redirect(url("./new"))
if os.path.exists("%s" % rpm_path):
flash(_(u'Failed to import because we already have %s' %
task_rpm.filename ))
redirect(url("./new"))
try:
def write_data(f):
siphon(task_rpm.file, f)
task = Task.update_task(task_rpm.filename, write_data)
except Exception, err:
session.rollback()
log.exception('Failed to import %s', task_rpm.filename)
flash(_(u'Failed to import task: %s' % err))
redirect(url("./new"))
示例2: upload
# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import update_task [as 别名]
def upload(self, task_rpm_name, task_rpm_data):
"""
Uploads a new task RPM.
:param task_rpm_name: filename of the task RPM, for example
``'beaker-distribution-install-1.10-11.noarch.rpm'``
:type task_rpm_name: string
:param task_rpm_data: contents of the task RPM
:type task_rpm_data: XML-RPC binary
"""
rpm_path = Task.get_rpm_path(task_rpm_name)
# we do it here, since we do not want to proceed
# any further
if len(task_rpm_name) > 255:
raise BX(_("Task RPM name should be <= 255 characters"))
if os.path.exists("%s" % rpm_path):
raise BX(_(u'Cannot import duplicate task %s') % task_rpm_name)
def write_data(f):
f.write(task_rpm_data.data)
Task.update_task(task_rpm_name, write_data)
return "Success"