本文整理汇总了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')