forked from luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.py
More file actions
64 lines (47 loc) · 1.62 KB
/
handlers.py
File metadata and controls
64 lines (47 loc) · 1.62 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright 2015 The LUCI Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.
import httplib
import webapp2
from components import decorators
from components.config.proto import service_config_pb2
import common
import gitiles_import
import notifications
import storage
class CronGitilesImport(webapp2.RequestHandler):
"""Imports configs from Gitiles."""
@decorators.require_cronjob
def get(self):
gitiles_import.cron_run_import()
class MainPageHandler(webapp2.RequestHandler):
"""Redirects to API Explorer."""
def get(self):
self.redirect('_ah/api/explorer')
class SchemasHandler(webapp2.RequestHandler):
"""Redirects to a known schema definition."""
def get(self, name):
cfg = storage.get_self_config_async(
common.SCHEMAS_FILENAME, service_config_pb2.SchemasCfg).get_result()
# Assume cfg was validated by validation.py
if cfg:
for schema in cfg.schemas:
if schema.name == name:
# Convert from unicode.
assert schema.url
self.redirect(str(schema.url))
return
self.response.write('Schema %s not found\n' % name)
self.response.set_status(httplib.NOT_FOUND)
def get_frontend_routes(): # pragma: no cover
return [
webapp2.Route(r'/', MainPageHandler),
webapp2.Route(r'/schemas/<name:.+>', SchemasHandler),
webapp2.Route(r'/_ah/bounce', notifications.BounceHandler),
]
def get_backend_routes(): # pragma: no cover
return [
webapp2.Route(
r'/internal/cron/luci-config/gitiles_import',
CronGitilesImport),
]