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


Python Project.rebuild_score方法代码示例

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


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

示例1: github_hook

# 需要导入模块: from project.models import Project [as 别名]
# 或者: from project.models.Project import rebuild_score [as 别名]
def github_hook(request):
    """
    github hook, when we get a request it will check to see if we have
    project already,
    if not, it will add it and trigger build. If we have it, it just
    triggers build.
    """
    log.debug("Github Hook")
    if request.method == 'POST':
        log.debug("Github Hook is POST")
        try:
            try:
                data = json.loads(request.POST['payload'])
            except Exception as exc:
                log.debug("(Github) parse request error = {0}".format(exc))
                return HttpResponse('Invalid payload')
            log.debug("-----")
            log.debug(data)
            log.debug("-----")
            repo = data.get('repository', {})
            name = repo.get('name', None)
            url = repo.get('url', "")
            url = url.replace('http://', 'https://')
            branch = data.get('ref', "").replace('refs/heads/', '')
            log.info("(Github Build) %s:%s" % (url, branch))

            try:
                project = Project.objects.get(repo_url=url)
                log.info("We have the project already {0}".format(project))
            except Project.DoesNotExist:
                log.info("New Project")
                project = Project()
                project.repo_url = url
                project.name = name
                project.save()
            log.info("Trigger build")
            project.rebuild_score()
        except Exception as exc:
            log.error("(Github) {0}".format(exc))
    else:
        log.debug("Github Hook was GET")
    log.info("Done webhook")
    return HttpResponse('Build Started')
开发者ID:DjangoLover,项目名称:scorinator,代码行数:45,代码来源:views.py


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