annotate bitten/trac_ext/web_ui.py @ 76:ffa1ffd8c7db

* Implement basic slave selection based on configured target platforms. Closes #15. * Simple build status overview in config view.
author cmlenz
date Tue, 05 Jul 2005 17:52:15 +0000
parents 1d4fa4c32afa
children 87098cbcdc90
rev   line source
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
1 # -*- coding: iso8859-1 -*-
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
2 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
3 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
4 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
5 # Bitten is free software; you can redistribute it and/or
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
6 # modify it under the terms of the GNU General Public License as
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
7 # published by the Free Software Foundation; either version 2 of the
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
8 # License, or (at your option) any later version.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
9 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
10 # Trac is distributed in the hope that it will be useful,
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
13 # General Public License for more details.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
14 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
18 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
19 # Author: Christopher Lenz <cmlenz@gmx.de>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
20
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
21 import re
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
22 from time import localtime, strftime
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
23
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
24 from trac.core import *
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
25 from trac.Timeline import ITimelineEventProvider
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
26 from trac.util import escape, pretty_timedelta
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
27 from trac.web.chrome import INavigationContributor, ITemplateProvider, \
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
28 add_link, add_stylesheet
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
29 from trac.web.main import IRequestHandler
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
30 from trac.wiki import wiki_to_html
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
31 from bitten.model import Build, BuildConfig, TargetPlatform
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
32
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
33
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
34 class BuildModule(Component):
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
35
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
36 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider,
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
37 ITemplateProvider)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
38
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
39 _status_label = {Build.IN_PROGRESS: 'in progress',
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
40 Build.SUCCESS: 'completed',
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
41 Build.FAILURE: 'failed'}
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
42
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
43 # INavigationContributor methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
44
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
45 def get_active_navigation_item(self, req):
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
46 return 'build'
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
47
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
48 def get_navigation_items(self, req):
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
49 if not req.perm.has_permission('BUILD_VIEW'):
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
50 return
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
51 yield 'mainnav', 'build', \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
52 '<a href="%s" accesskey="5">Build Status</a>' \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
53 % self.env.href.build()
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
54
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
55 # IRequestHandler methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
56
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
57 def match_request(self, req):
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
58 match = re.match(r'/build(?:/([\w.-]+))?(?:/([\d]+))?', req.path_info)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
59 if match:
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
60 if match.group(1):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
61 req.args['config'] = match.group(1)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
62 if match.group(2):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
63 req.args['id'] = match.group(2)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
64 return True
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
65
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
66 def process_request(self, req):
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
67 req.perm.assert_permission('BUILD_VIEW')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
68
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
69 action = req.args.get('action')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
70 config = req.args.get('config')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
71 id = req.args.get('id')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
72
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
73 if req.method == 'POST':
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
74 if config:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
75 if action == 'new':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
76 self._do_create_platform(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
77 else:
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
78 self.log.debug('Request args: %s', req.args.keys())
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
79 platform_id = req.args.get('platform')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
80 if platform_id:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
81 if action == 'edit':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
82 self._do_save_platform(req, config, platform_id)
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
83 elif 'delete' in req.args.keys():
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
84 self._do_delete_platforms(req)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
85 self._render_config_form(req, config)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
86 elif 'new' in req.args.keys():
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
87 platform = TargetPlatform(self.env)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
88 platform.config = config
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
89 self._render_platform_form(req, platform)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
90 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
91 self._do_save_config(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
92 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
93 if action == 'new':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
94 self._do_create_config(req)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
95 else:
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
96 if id:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
97 self._render_build(req, id)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
98 elif config:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
99 if action == 'edit':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
100 platform_id = req.args.get('platform')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
101 if platform_id:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
102 platform = TargetPlatform(self.env, int(platform_id))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
103 self._render_platform_form(req, platform)
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
104 elif 'new' in req.args.keys():
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
105 platform = TargetPlatform(self.env)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
106 self._render_platform_form(req, platform)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
107 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
108 self._render_config_form(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
109 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
110 self._render_config(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
111 else:
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
112 if action == 'new':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
113 self._render_config_form(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
114 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
115 self._render_overview(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
116
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
117 add_stylesheet(req, 'build.css')
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
118 return 'build.cs', None
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
119
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
120 # ITemplatesProvider methods
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
121
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
122 def get_htdocs_dir(self):
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
123 return self.config.get('bitten', 'htdocs_dir')
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
124
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
125 def get_templates_dir(self):
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
126 return self.config.get('bitten', 'templates_dir')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
127
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
128 # ITimelineEventProvider methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
129
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
130 def get_timeline_filters(self, req):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
131 if req.perm.has_permission('BUILD_VIEW'):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
132 yield ('build', 'Builds')
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
133
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
134 def get_timeline_events(self, req, start, stop, filters):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
135 if 'build' in filters:
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
136 add_stylesheet(req, 'build.css')
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
137 db = self.env.get_db_cnx()
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
138 cursor = db.cursor()
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
139 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name,b.slave,"
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
140 "b.stopped,b.status FROM bitten_build AS b"
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
141 " INNER JOIN bitten_config AS c ON (c.name=b.config)"
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
142 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) "
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
143 "WHERE b.stopped>=%s AND b.stopped<=%s "
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
144 "AND b.status IN (%s, %s) ORDER BY b.stopped",
67
6ffa99b442bf Fix error in timeline when builds are in progress.
cmlenz
parents: 65
diff changeset
145 (start, stop, Build.SUCCESS, Build.FAILURE))
65
5f9bcb4966b7 Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents: 64
diff changeset
146 event_kinds = {Build.SUCCESS: 'successbuild',
5f9bcb4966b7 Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents: 64
diff changeset
147 Build.FAILURE: 'failedbuild'}
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
148 for id, config, label, rev, platform, slave, stopped, status in cursor:
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
149 title = 'Build of <em>%s [%s]</em> by %s (%s) %s' \
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
150 % (escape(label), escape(rev), escape(slave),
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
151 escape(platform), self._status_label[status])
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
152 href = self.env.href.build(config, id)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
153 yield event_kinds[status], href, title, stopped, None, ''
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
154
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
155 # Internal methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
156
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
157 def _do_create_config(self, req):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
158 """Create a new build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
159 req.perm.assert_permission('BUILD_CREATE')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
160
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
161 if 'cancel' in req.args.keys():
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
162 req.redirect(self.env.href.build())
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
163
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
164 config = BuildConfig(self.env)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
165 config.name = req.args.get('name')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
166 config.active = req.args.has_key('active')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
167 config.label = req.args.get('label', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
168 config.path = req.args.get('path', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
169 config.description = req.args.get('description', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
170 config.insert()
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
171
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
172 req.redirect(self.env.href.build(config.name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
173
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
174 def _do_save_config(self, req, config_name):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
175 """Save changes to a build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
176 req.perm.assert_permission('BUILD_MODIFY')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
177
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
178 if 'cancel' in req.args.keys():
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
179 req.redirect(self.env.href.build(config_name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
180
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
181 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
182 config.name = req.args.get('name')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
183 config.active = req.args.has_key('active')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
184 config.label = req.args.get('label', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
185 config.path = req.args.get('path', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
186 config.description = req.args.get('description', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
187 config.update()
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
188
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
189 req.redirect(self.env.href.build(config.name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
190
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
191 def _do_create_platform(self, req, config_name):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
192 """Create a new target platform."""
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
193 req.perm.assert_permission('BUILD_MODIFY')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
194
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
195 if 'cancel' in req.args.keys():
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
196 req.redirect(self.env.href.build(config_name, action='edit'))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
197
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
198 platform = TargetPlatform(self.env)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
199 platform.config = config_name
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
200 platform.name = req.args.get('name')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
201
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
202 properties = [int(key[9:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
203 if key.startswith('property_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
204 properties.sort()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
205 patterns = [int(key[8:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
206 if key.startswith('pattern_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
207 patterns.sort()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
208 platform.rules = [(req.args.get('property_%d' % property),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
209 req.args.get('pattern_%d' % pattern))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
210 for property, pattern in zip(properties, patterns)]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
211
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
212 add_rules = [int(key[9:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
213 if key.startswith('add_rule_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
214 if add_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
215 platform.rules.insert(add_rules[0] + 1, ('', ''))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
216 self._render_platform_form(req, platform)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
217 return
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
218 rm_rules = [int(key[8:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
219 if key.startswith('rm_rule_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
220 if rm_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
221 del platform.rules[rm_rules[0]]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
222 self._render_platform_form(req, platform)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
223 return
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
224
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
225 platform.insert()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
226
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
227 req.redirect(self.env.href.build(config_name, action='edit'))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
228
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
229 def _do_delete_platforms(self, req):
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
230 """Delete selected target platforms."""
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
231 req.perm.assert_permission('BUILD_MODIFY')
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
232 self.log.debug('_do_delete_platforms')
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
233
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
234 db = self.env.get_db_cnx()
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
235 for platform_id in [int(id) for id in req.args.get('delete_platform')]:
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
236 platform = TargetPlatform(self.env, platform_id, db=db)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
237 self.log.info('Deleting target platform %s of configuration %s',
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
238 platform.name, platform.config)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
239 platform.delete(db=db)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
240 db.commit()
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
241
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
242 def _do_save_platform(self, req, config_name, platform_id):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
243 """Save changes to a target platform."""
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
244 req.perm.assert_permission('BUILD_MODIFY')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
245
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
246 if 'cancel' in req.args.keys():
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
247 req.redirect(self.env.href.build(config_name, action='edit'))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
248
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
249 platform = TargetPlatform(self.env, platform_id)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
250 platform.name = req.args.get('name')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
251
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
252 properties = [int(key[9:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
253 if key.startswith('property_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
254 properties.sort()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
255 patterns = [int(key[8:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
256 if key.startswith('pattern_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
257 patterns.sort()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
258 platform.rules = [(req.args.get('property_%d' % property),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
259 req.args.get('pattern_%d' % pattern))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
260 for property, pattern in zip(properties, patterns)]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
261
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
262 add_rules = [int(key[9:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
263 if key.startswith('add_rule_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
264 if add_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
265 platform.rules.insert(add_rules[0] + 1, ('', ''))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
266 self._render_platform_form(req, platform)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
267 return
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
268 rm_rules = [int(key[8:]) for key in req.args.keys()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
269 if key.startswith('rm_rule_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
270 if rm_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
271 del platform.rules[rm_rules[0]]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
272 self._render_platform_form(req, platform)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
273 return
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
274
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
275 platform.update()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
276
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
277 req.redirect(self.env.href.build(config_name, action='edit'))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
278
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
279 def _render_overview(self, req):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
280 req.hdf['title'] = 'Build Status'
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
281 configurations = BuildConfig.select(self.env, include_inactive=True)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
282 for idx, config in enumerate(configurations):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
283 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
284 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
285 description = wiki_to_html(description, self.env, req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
286 req.hdf['build.configs.%d' % idx] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
287 'name': config.name, 'label': config.label or config.name,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
288 'path': config.path, 'description': description,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
289 'href': self.env.href.build(config.name)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
290 }
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
291 req.hdf['build.mode'] = 'overview'
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
292 req.hdf['build.can_create'] = req.perm.has_permission('BUILD_CREATE')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
293
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
294 def _render_config(self, req, config_name):
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
295 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
296 req.hdf['title'] = 'Build Configuration "%s"' \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
297 % escape(config.label or config.name)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
298 add_link(req, 'up', self.env.href.build(), 'Build Status')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
299 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
300 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
301 description = wiki_to_html(description, self.env, req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
302 req.hdf['build.config'] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
303 'name': config.name, 'label': config.label, 'path': config.path,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
304 'active': config.active, 'description': description,
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
305 'browser_href': self.env.href.browser(config.path),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
306 'can_modify': req.perm.has_permission('BUILD_MODIFY')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
307 }
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
308 req.hdf['build.mode'] = 'view_config'
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
309
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
310 platforms = TargetPlatform.select(self.env, config=config_name)
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
311 req.hdf['build.platforms'] = [
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
312 {'name': platform.name, 'id': platform.id} for platform in platforms
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
313 ]
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
314
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
315 repos = self.env.get_repository(req.authname)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
316 root = repos.get_node(config.path)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
317 num = 0
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
318 for idx, (path, rev, chg) in enumerate(root.get_history()):
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
319 prefix = 'build.builds.%d' % rev
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
320 req.hdf[prefix + '.href'] = self.env.href.changeset(rev)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
321 for build in Build.select(self.env, config=config.name, rev=rev):
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
322 if build.status == Build.PENDING:
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
323 continue
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
324 req.hdf['%s.%s' % (prefix, build.platform)] = self._build_to_hdf(build)
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
325 if idx > 4:
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
326 break
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
327
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
328 def _render_config_form(self, req, config_name=None):
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
329 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
330 if config.exists:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
331 req.perm.assert_permission('BUILD_MODIFY')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
332 req.hdf['build.config'] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
333 'name': config.name, 'label': config.label, 'path': config.path,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
334 'active': config.active, 'description': config.description,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
335 'exists': config.exists
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
336 }
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
337
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
338 req.hdf['title'] = 'Edit Build Configuration "%s"' \
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
339 % escape(config.label or config.name)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
340 for idx, platform in enumerate(TargetPlatform.select(self.env,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
341 config_name)):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
342 req.hdf['build.platforms.%d' % idx] = {
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
343 'id': platform.id, 'name': platform.name,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
344 'href': self.env.href.build(config_name, action='edit',
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
345 platform=platform.id)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
346 }
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
347 else:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
348 req.perm.assert_permission('BUILD_CREATE')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
349 req.hdf['title'] = 'Create Build Configuration'
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
350 req.hdf['build.mode'] = 'edit_config'
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
351
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
352 def _render_platform_form(self, req, platform):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
353 req.perm.assert_permission('BUILD_MODIFY')
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
354 if platform.exists:
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
355 req.hdf['title'] = 'Edit Target Platform "%s"' \
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
356 % escape(platform.name)
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
357 else:
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
358 req.hdf['title'] = 'Add Target Platform'
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
359 req.hdf['build.platform'] = {
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
360 'name': platform.name, 'id': platform.id, 'exists': platform.exists,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
361 'rules': [{'property': propname, 'pattern': pattern}
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
362 for propname, pattern in platform.rules] + [('', '')]
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
363 }
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
364 req.hdf['build.mode'] = 'edit_platform'
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
365
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
366 def _render_build(self, req, build_id):
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
367 build = Build(self.env, build_id)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
368 assert build.exists
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
369 add_link(req, 'up', self.env.href.build(build.config),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
370 'Build Configuration')
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
371 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure'}
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
372 req.hdf['title'] = 'Build %s - %s' % (build_id,
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
373 status2title[build.status])
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
374 req.hdf['build'] = self._build_to_hdf(build)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
375 req.hdf['build.mode'] = 'view_build'
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
376
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
377 config = BuildConfig(self.env, build.config)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
378 req.hdf['build.config'] = {
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
379 'name': config.label,
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
380 'href': self.env.href.build(config.name)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
381 }
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
382
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
383 def _build_to_hdf(self, build):
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
384 hdf = {'id': build.id, 'name': build.slave, 'rev': build.rev,
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
385 'status': self._status_label[build.status],
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
386 'cls': self._status_label[build.status].replace(' ', '-'),
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
387 'href': self.env.href.build(build.config, build.id),
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
388 'chgset_href': self.env.href.changeset(build.rev)}
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
389 if build.started:
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
390 hdf['started'] = strftime('%x %X', localtime(build.started))
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
391 hdf['started_delta'] = pretty_timedelta(build.started)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
392 if build.stopped:
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
393 hdf['stopped'] = strftime('%x %X', localtime(build.stopped))
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
394 hdf['stopped_delta'] = pretty_timedelta(build.stopped)
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
395 hdf['duration'] = pretty_timedelta(build.stopped, build.started)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
396 hdf['slave'] = {
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
397 'name': build.slave,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
398 'ip_address': build.slave_info.get(Build.IP_ADDRESS),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
399 'os': build.slave_info.get(Build.OS_NAME),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
400 'os.family': build.slave_info.get(Build.OS_FAMILY),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
401 'os.version': build.slave_info.get(Build.OS_VERSION),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
402 'machine': build.slave_info.get(Build.MACHINE),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
403 'processor': build.slave_info.get(Build.PROCESSOR)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
404 }
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
405 return hdf
Copyright (C) 2012-2017 Edgewall Software