本文整理汇总了Python中models.Author.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Author.gql方法的具体用法?Python Author.gql怎么用?Python Author.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Author
的用法示例。
在下文中一共展示了Author.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: worker_authors
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import gql [as 别名]
def worker_authors(request):
r = Repository.get(db.Key(request.POST["repo"]))
logging.info("processing repository: %s" % r.name)
base_url = "http://github.com/%s/%s" % (r.owner.name, r.name)
url = base_url + "/network_meta"
logging.info(" downloading network_meta from: %s" % url)
try:
s = urllib2.urlopen(url).read()
except urllib2.HTTPError:
logging.info("Probably bad repo, skipping.")
return HttpResponse("Probably bad repo, skipping.\n")
logging.info(" network_meta loaded")
try:
data = simplejson.loads(s)
except ValueError:
logging.info("Probably bad repo, skipping.")
return HttpResponse("Probably bad repo, skipping.\n")
logging.info(" network_meta parsed")
dates = data["dates"]
nethash = data["nethash"]
url = "%s/network_data_chunk?nethash=%s&start=0&end=%d" % (base_url,
nethash, len(dates)-1)
logging.info(" downloading commits from: %s" % url)
s = urllib2.urlopen(url).read()
logging.info(" parsing commits...")
data = simplejson.loads(s, encoding="latin-1")
logging.info(" processing authors...")
commits = data["commits"]
m = [(x["author"], x["id"]) for x in commits]
m = dict(m)
logging.info(m)
authors = m.keys()
authors = list(set(authors))
authors.sort()
logging.info(authors)
queue = get_github_queue()
for author in authors:
q = User.gql("WHERE name = :1", author)
u = q.get()
if u is None:
u = User(name=author, email="None")
u.save()
task = taskqueue.Task(url="/hooks/worker/user_email/",
params={'user': u.key(),
'r_user_id': r.owner.name,
'r_repository': r.name,
'r_sha': m[u.name]
})
queue.add(task)
q = Author.gql("WHERE user = :1 AND repo = :2", u, r)
a = q.get()
if a is None:
a = Author(repo=r, user=u)
a.save()
logging.info(" done.")
return HttpResponse("OK\n")
示例2: repo
# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import gql [as 别名]
def repo(request, repo):
r = Repository.get(db.Key(repo))
repo_url = "http://github.com/%s/%s" % (r.owner.name, r.name)
updates = RepoUpdate.gql("WHERE repo = :1", r)
authors = Author.gql("WHERE repo = :1", r)
a = []
for author in authors:
u = author.user
a.append({"name": u.name, "email": u.email, "key": u.key(),
"gravatar_url": get_gravatar_url(u.email)})
return render_to_response("hooks/repo.html", {'repo': r,
'repo_url': repo_url, 'updates': updates, 'authors': a})