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


Python Project.get_project_for_name方法代码示例

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


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

示例1: UploadBundle

# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import get_project_for_name [as 别名]
  def UploadBundle(self, rpc_controller, req, done):
    """
      Receives an uploaded Git style bundle and queues it for processing.
    """
    rsp = UploadBundleResponse()

    # can't get here if there isn't a current user
    current_user = users.get_current_user()
    
    if not Account.get_account_for_user(current_user).cla_verified:
      rsp.status_code = UploadBundleResponse.UNAUTHORIZED_USER
      done(rsp)
      return

    # Validate that we have an Account for everyone in reviewers
    invalid_reviewers = []
    reviewers = Account.get_accounts_for_emails([x for x in req.reviewers])
    for i in range(0, len(reviewers)):
      if not reviewers[i]:
        invalid_reviewers.append(req.reviewers[i])

    # Validate all of the email addresses
    invalid_cc = []
    for e in req.cc:
      if not forms.fields.email_re.search(e):
        invalid_cc.append(e)

    # Return failure if any of that was bad
    if invalid_reviewers or invalid_cc:
      rsp.status_code = UploadBundleResponse.UNKNOWN_EMAIL
      for e in invalid_reviewers:
        rsp.invalid_reviewers.append(e)
      for e in invalid_cc:
        rsp.invalid_cc.append(e)
      done(rsp)
      return

    reviewers = [x.user for x in reviewers]
    cc = [db.Email(x) for x in req.cc]

    if not req.dest_project:
      rsp.status_code = UploadBundleResponse.UNKNOWN_PROJECT
      done(rsp)
      return

    proj = req.dest_project
    if proj.endswith(".git"):
      proj = proj[0 : len(proj) - 4]

    proj = Project.get_project_for_name(proj)
    if not proj:
      rsp.status_code = UploadBundleResponse.UNKNOWN_PROJECT
      done(rsp)
      return

    if not req.dest_branch:
      rsp.status_code = UploadBundleResponse.UNKNOWN_BRANCH
      done(rsp)

    brch = Branch.get_branch_for_name(proj, req.dest_branch)
    if not brch:
      rsp.status_code = UploadBundleResponse.UNKNOWN_BRANCH
      done(rsp)
      return

    replaces = list()
    ids_to_check = list()
    for p in req.replace:
      id = int(p.change_id)
      ids_to_check.append(id)
      replaces.append('%d %s' % (id, p.object_id))

    if ids_to_check:
      for id, c in zip(ids_to_check, Change.get_by_id(ids_to_check)):
        if not c:
          rsp.status_code = UploadBundleResponse.UNKNOWN_CHANGE
          done(rsp)
          return
        if c.closed:
          rsp.status_code = UploadBundleResponse.CHANGE_CLOSED
          done(rsp)
          return

    rb = git_models.ReceivedBundle(
      dest_project = proj,
      dest_branch = brch,
      owner = current_user,
      state = git_models.ReceivedBundle.STATE_UPLOADING,
      reviewers = reviewers,
      cc = cc,
      contained_objects = list(req.contained_object),
      replaces = replaces)
    rb.put()

    rsp.bundle_id = str(rb.key().id())
    self._store_segment(req, rsp, rb, 1)
    done(rsp)
开发者ID:Shrews,项目名称:PyGerrit,代码行数:99,代码来源:review_service.py


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