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


Python Task.get_rpm_path方法代码示例

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


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

示例1: save

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import get_rpm_path [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"))
开发者ID:omps,项目名称:beaker,代码行数:32,代码来源:tasks.py

示例2: upload

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import get_rpm_path [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"
开发者ID:omps,项目名称:beaker,代码行数:24,代码来源:tasks.py


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