forked from googlearchive/cloud-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
42 lines (31 loc) · 1.32 KB
/
Copy pathtasks.py
File metadata and controls
42 lines (31 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Module containing template WSGI handlers."""
import webapp2
from . import model
from . import shared
from template import templates
class PopulateRepoCollection(webapp2.RequestHandler):
def post(self): # pylint:disable-msg=invalid-name
repo_collection_url = self.request.get('repo_collection_url')
shared.i('task {} populating repo collection {}'
.format(shared.GetCurrentTaskName(), repo_collection_url))
collection = templates.GetCollection(repo_collection_url)
if not collection:
shared.e('missing repo collection {}'.format(repo_collection_url))
collection.PopulateRepos()
templates.ClearCache()
class PopulateRepo(webapp2.RequestHandler):
def post(self): # pylint:disable-msg=invalid-name
repo_url = self.request.get('repo_url')
shared.i('task {} populating repo {}'.format(shared.GetCurrentTaskName(),
repo_url))
repo = model.GetRepo(repo_url)
collection = templates.GetCollection(repo_url)
if not collection:
project = repo.project.get()
model.DeleteProject(project)
return
collection.CreateTemplateProject(repo)
app = webapp2.WSGIApplication([
('/_playground_tasks/populate_repo_collection', PopulateRepoCollection),
('/_playground_tasks/populate_repo', PopulateRepo),
], debug=True)