| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Main entry point for Swarming service. | 5 """Main entry point for Swarming service. |
| 6 | 6 |
| 7 This file contains the URL handlers for all the Swarming service URLs, | 7 This file contains the URL handlers for all the Swarming service URLs, |
| 8 implemented using the webapp2 framework. | 8 implemented using the webapp2 framework. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 params['mapreduce_jobs'] = [ | 737 params['mapreduce_jobs'] = [ |
| 738 {'id': job_id, 'name': job_def['job_name']} | 738 {'id': job_id, 'name': job_def['job_name']} |
| 739 for job_id, job_def in mapreduce_jobs.MAPREDUCE_JOBS.iteritems() | 739 for job_id, job_def in mapreduce_jobs.MAPREDUCE_JOBS.iteritems() |
| 740 ] | 740 ] |
| 741 params['xsrf_token'] = self.generate_xsrf_token() | 741 params['xsrf_token'] = self.generate_xsrf_token() |
| 742 if acl.is_bootstrapper(): | 742 if acl.is_bootstrapper(): |
| 743 params['bootstrap_token'] = bot_code.generate_bootstrap_token() | 743 params['bootstrap_token'] = bot_code.generate_bootstrap_token() |
| 744 self.response.write(template.render('swarming/root.html', params)) | 744 self.response.write(template.render('swarming/root.html', params)) |
| 745 | 745 |
| 746 | 746 |
| 747 class UIHandler(auth.AuthenticatingHandler): |
| 748 @auth.public |
| 749 def get(self, page): |
| 750 if not page: |
| 751 page = "swarming" |
| 752 |
| 753 params = { |
| 754 'client_id': config.settings().ui_client_id, |
| 755 } |
| 756 self.response.write(template.render( |
| 757 'swarming/public_%s_index.html' % page, params)) |
| 758 |
| 759 |
| 747 class WarmupHandler(webapp2.RequestHandler): | 760 class WarmupHandler(webapp2.RequestHandler): |
| 748 def get(self): | 761 def get(self): |
| 749 auth.warmup() | 762 auth.warmup() |
| 750 bot_code.get_swarming_bot_zip(self.request.host_url) | 763 bot_code.get_swarming_bot_zip(self.request.host_url) |
| 751 utils.get_module_version_list(None, None) | 764 utils.get_module_version_list(None, None) |
| 752 self.response.headers['Content-Type'] = 'text/plain; charset=utf-8' | 765 self.response.headers['Content-Type'] = 'text/plain; charset=utf-8' |
| 753 self.response.write('ok') | 766 self.response.write('ok') |
| 754 | 767 |
| 755 | 768 |
| 756 class EmailHandler(webapp2.RequestHandler): | 769 class EmailHandler(webapp2.RequestHandler): |
| 757 """Blackhole any email sent.""" | 770 """Blackhole any email sent.""" |
| 758 def post(self, to): | 771 def post(self, to): |
| 759 pass | 772 pass |
| 760 | 773 |
| 761 | 774 |
| 762 def create_application(debug): | 775 def create_application(debug): |
| 763 template.bootstrap() | 776 template.bootstrap() |
| 764 utils.set_task_queue_module('default') | 777 utils.set_task_queue_module('default') |
| 765 | 778 |
| 766 routes = [ | 779 routes = [ |
| 767 # Frontend pages. They return HTML. | 780 # Frontend pages. They return HTML. |
| 768 # Public pages. | 781 # Public pages. |
| 769 ('/', RootHandler), | 782 ('/', RootHandler), |
| 770 ('/stats', stats_gviz.StatsSummaryHandler), | 783 ('/stats', stats_gviz.StatsSummaryHandler), |
| 784 ('/newui/<page:[a-z]*>', UIHandler), |
| 771 | 785 |
| 772 # User pages. | 786 # User pages. |
| 773 ('/user/tasks', TasksHandler), | 787 ('/user/tasks', TasksHandler), |
| 774 ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler), | 788 ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler), |
| 775 ('/user/task/<task_id:[0-9a-fA-F]+>/cancel', TaskCancelHandler), | 789 ('/user/task/<task_id:[0-9a-fA-F]+>/cancel', TaskCancelHandler), |
| 776 ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler), | 790 ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler), |
| 777 | 791 |
| 778 # Privileged user pages. | 792 # Privileged user pages. |
| 779 ('/restricted/bots', BotsListHandler), | 793 ('/restricted/bots', BotsListHandler), |
| 780 ('/restricted/bot/<bot_id:[^/]+>', BotHandler), | 794 ('/restricted/bot/<bot_id:[^/]+>', BotHandler), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 802 | 816 |
| 803 # If running on a local dev server, allow bots to connect without prior | 817 # If running on a local dev server, allow bots to connect without prior |
| 804 # groups configuration. Useful when running smoke test. | 818 # groups configuration. Useful when running smoke test. |
| 805 if utils.is_local_dev_server(): | 819 if utils.is_local_dev_server(): |
| 806 acl.bootstrap_dev_server_acls() | 820 acl.bootstrap_dev_server_acls() |
| 807 | 821 |
| 808 routes.extend(handlers_backend.get_routes()) | 822 routes.extend(handlers_backend.get_routes()) |
| 809 routes.extend(handlers_bot.get_routes()) | 823 routes.extend(handlers_bot.get_routes()) |
| 810 routes.extend(handlers_endpoints.get_routes()) | 824 routes.extend(handlers_endpoints.get_routes()) |
| 811 return webapp2.WSGIApplication(routes, debug=debug) | 825 return webapp2.WSGIApplication(routes, debug=debug) |
| OLD | NEW |