本文整理匯總了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"