Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: appengine/swarming/handlers_frontend.py

Issue 2267363004: Add CIPD pin reporting to swarming. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if not request or not result: 609 if not request or not result:
610 self.abort(404, '%s not found.' % key.id()) 610 self.abort(404, '%s not found.' % key.id())
611 if not request.has_access: 611 if not request.has_access:
612 self.abort(403, '%s is not accessible.' % key.id()) 612 self.abort(403, '%s is not accessible.' % key.id())
613 return request, result 613 return request, result
614 614
615 615
616 class TaskHandler(BaseTaskHandler): 616 class TaskHandler(BaseTaskHandler):
617 """Show the full text of a task request and its result.""" 617 """Show the full text of a task request and its result."""
618 618
619 @staticmethod
620 def packages_grouped_by_path(flat_packages):
621 """Returns sorted [(path, [PinInfo, ...])].
622
623 Used by user_task.html.
624 """
625 retval = collections.defaultdict(list)
626 for pkg in flat_packages:
627 retval[pkg.path].append(pkg)
628 return sorted(retval.iteritems())
629
619 @auth.autologin 630 @auth.autologin
620 @auth.require(acl.is_user) 631 @auth.require(acl.is_user)
621 def get(self, task_id): 632 def get(self, task_id):
622 request, result = self.get_request_and_result(task_id) 633 request, result = self.get_request_and_result(task_id)
623 parent_task_future = None 634 parent_task_future = None
624 if request.parent_task_id: 635 if request.parent_task_id:
625 parent_key = task_pack.unpack_run_result_key(request.parent_task_id) 636 parent_key = task_pack.unpack_run_result_key(request.parent_task_id)
626 parent_task_future = parent_key.get_async() 637 parent_task_future = parent_key.get_async()
627 children_tasks_futures = [ 638 children_tasks_futures = [
628 task_pack.unpack_result_summary_key(c).get_async() 639 task_pack.unpack_result_summary_key(c).get_async()
(...skipping 27 matching lines...) Expand all
656 667
657 previous_task = None 668 previous_task = None
658 if previous_task_future: 669 if previous_task_future:
659 previous_task = previous_task_future.get_result() 670 previous_task = previous_task_future.get_result()
660 671
661 parent_task = None 672 parent_task = None
662 if parent_task_future: 673 if parent_task_future:
663 parent_task = parent_task_future.get_result() 674 parent_task = parent_task_future.get_result()
664 children_tasks = [c.get_result() for c in children_tasks_futures] 675 children_tasks = [c.get_result() for c in children_tasks_futures]
665 676
677 cipd = None
678 if request.properties.cipd_input:
679 cipd = {
680 'server': request.properties.cipd_input.server,
681 'client_package': request.properties.cipd_input.client_package,
682 'packages': self.packages_grouped_by_path(
683 request.properties.cipd_input.packages)
M-A Ruel 2016/08/30 18:54:12 keep trailing comma
iannucci 2016/08/30 19:09:17 Done
684 }
685
686 cipd_pins = None
687 if result.cipd_pins:
688 cipd_pins = {
689 'client_package': result.cipd_pins.client_package,
690 'packages': self.packages_grouped_by_path(result.cipd_pins.packages),
691 }
692
666 params = { 693 params = {
667 'bot': bot_future.get_result() if bot_future else None, 694 'bot': bot_future.get_result() if bot_future else None,
668 'children_tasks': children_tasks, 695 'children_tasks': children_tasks,
696 'cipd': cipd,
697 'cipd_pins': cipd_pins,
669 'is_admin': acl.is_admin(), 698 'is_admin': acl.is_admin(),
670 'is_gae_admin': users.is_current_user_admin(), 699 'is_gae_admin': users.is_current_user_admin(),
671 'is_privileged_user': acl.is_privileged_user(), 700 'is_privileged_user': acl.is_privileged_user(),
672 'following_task': following_task, 701 'following_task': following_task,
673 'full_appid': os.environ['APPLICATION_ID'], 702 'full_appid': os.environ['APPLICATION_ID'],
674 'host_url': self.request.host_url, 703 'host_url': self.request.host_url,
675 'is_running': result.state == task_result.State.RUNNING, 704 'is_running': result.state == task_result.State.RUNNING,
676 'parent_task': parent_task, 705 'parent_task': parent_task,
677 'previous_task': previous_task, 706 'previous_task': previous_task,
678 'request': request, 707 'request': request,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 845
817 # If running on a local dev server, allow bots to connect without prior 846 # If running on a local dev server, allow bots to connect without prior
818 # groups configuration. Useful when running smoke test. 847 # groups configuration. Useful when running smoke test.
819 if utils.is_local_dev_server(): 848 if utils.is_local_dev_server():
820 acl.bootstrap_dev_server_acls() 849 acl.bootstrap_dev_server_acls()
821 850
822 routes.extend(handlers_backend.get_routes()) 851 routes.extend(handlers_backend.get_routes())
823 routes.extend(handlers_bot.get_routes()) 852 routes.extend(handlers_bot.get_routes())
824 routes.extend(handlers_endpoints.get_routes()) 853 routes.extend(handlers_endpoints.get_routes())
825 return webapp2.WSGIApplication(routes, debug=debug) 854 return webapp2.WSGIApplication(routes, debug=debug)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698