1 #!/usr/bin/env python 2 # 3 # Copyright (C) 2017 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 import os 19 20 import webapp2 21 22 from webapp.src.dashboard import build_list 23 from webapp.src.dashboard import device_list 24 from webapp.src.dashboard import job_list 25 from webapp.src.dashboard import schedule_list 26 from webapp.src.handlers.base import BaseHandler 27 from webapp.src.scheduler import device_heartbeat 28 from webapp.src.scheduler import job_heartbeat 29 from webapp.src.scheduler import periodic 30 from webapp.src.tasks import indexing 31 32 33 class MainPage(BaseHandler): 34 """Main web page request handler.""" 35 36 def get(self): 37 """Generates an HTML page.""" 38 self.template = "index.html" 39 40 template_values = {} 41 42 self.render(template_values) 43 44 45 config = {} 46 config['webapp2_extras.sessions'] = { 47 'secret_key': os.environ.get('SESSION_SECRET_KEY'), 48 } 49 50 app = webapp2.WSGIApplication( 51 [ 52 ("/", MainPage), ("/build", build_list.BuildPage), 53 ("/device", device_list.DevicePage), ("/job", job_list.JobPage), 54 ("/create_job", job_list.CreateJobPage), 55 ("/create_job_template", job_list.CreateJobTemplatePage), 56 ("/result", MainPage), ("/schedule", schedule_list.SchedulePage), 57 ("/tasks/schedule", periodic.PeriodicScheduler), 58 ("/tasks/device_heartbeat", device_heartbeat.PeriodicDeviceHeartBeat), 59 ("/tasks/job_heartbeat", job_heartbeat.PeriodicJobHeartBeat), 60 ("/tasks/indexing", indexing.CreateIndex), 61 ("/tasks/indexing/build", indexing.CreateBuildModelIndex), 62 ("/tasks/indexing/device", indexing.CreateDeviceModelIndex), 63 ("/tasks/indexing/job", indexing.CreateJobModelIndex), 64 ("/tasks/indexing/lab", indexing.CreateLabModelIndex), 65 ("/tasks/indexing/schedule", indexing.CreateScheduleModelIndex) 66 ], 67 config=config, 68 debug=False) 69