Mercurial > bitten > bitten-test
annotate bitten/trac_ext/web_ui.py @ 197:d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
* Only display charts on build config page when reports are available.
* BDB XML database is created lazily, i.e. only on write requests.
author | cmlenz |
---|---|
date | Tue, 13 Sep 2005 10:32:25 +0000 |
parents | b5f7d8a4035e |
children | 6bb8e7a18072 |
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> |
163 | 4 # All rights reserved. |
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
|
5 # |
163 | 6 # This software is licensed as described in the file COPYING, which |
7 # you should have received as part of this distribution. The terms | |
8 # are also available at http://bitten.cmlenz.net/wiki/License. | |
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
|
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 import re |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
11 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
|
12 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
13 import pkg_resources |
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
|
14 from trac.core import * |
64 | 15 from trac.Timeline import ITimelineEventProvider |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
16 from trac.util import escape, pretty_timedelta |
174
79c61c26a4e1
* Changed the `IReportStore` interface to allow querying with [http://www.w3.org/XML/Query/ XQuery]. This should make it possible to efficiently query the report store for any existing metrics.
cmlenz
parents:
168
diff
changeset
|
17 from trac.web import IRequestHandler |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
18 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
|
19 add_link, add_stylesheet |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
20 from trac.wiki import wiki_to_html |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
21 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, BuildLog |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
22 from bitten.store import get_store |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
23 from bitten.trac_ext.api import ILogFormatter, IReportSummarizer |
114
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
24 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
25 _status_label = {Build.IN_PROGRESS: 'in progress', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
26 Build.SUCCESS: 'completed', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
27 Build.FAILURE: 'failed'} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
28 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
29 def _build_to_hdf(env, req, build): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
30 hdf = {'id': build.id, 'name': build.slave, 'rev': build.rev, |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
31 'status': _status_label[build.status], |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
32 'cls': _status_label[build.status].replace(' ', '-'), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
33 'href': env.href.build(build.config, build.id), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
34 'chgset_href': env.href.changeset(build.rev)} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
35 if build.started: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
36 hdf['started'] = strftime('%x %X', localtime(build.started)) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
37 hdf['started_delta'] = pretty_timedelta(build.started) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
38 if build.stopped: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
39 hdf['stopped'] = strftime('%x %X', localtime(build.stopped)) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
40 hdf['stopped_delta'] = pretty_timedelta(build.stopped) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
41 hdf['duration'] = pretty_timedelta(build.stopped, build.started) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
42 hdf['slave'] = { |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
43 'name': build.slave, |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
44 'ip_address': build.slave_info.get(Build.IP_ADDRESS), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
45 'os': build.slave_info.get(Build.OS_NAME), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
46 'os.family': build.slave_info.get(Build.OS_FAMILY), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
47 'os.version': build.slave_info.get(Build.OS_VERSION), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
48 'machine': build.slave_info.get(Build.MACHINE), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
49 'processor': build.slave_info.get(Build.PROCESSOR) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
50 } |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
51 return hdf |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
52 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
53 class BittenChrome(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
54 """Provides the Bitten templates and static resources.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
55 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
56 implements(ITemplateProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
57 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
58 # ITemplatesProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
59 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
60 def get_htdocs_dirs(self): |
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
61 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))] |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
62 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
63 def get_templates_dirs(self): |
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
64 return [pkg_resources.resource_filename(__name__, 'templates')] |
114
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
65 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
66 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
67 class BuildConfigController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
68 """Implements the web interface for build configurations.""" |
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
|
69 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
70 implements(INavigationContributor, IRequestHandler) |
64 | 71 |
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
|
72 # 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
|
73 |
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
|
74 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
|
75 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
|
76 |
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
|
77 def get_navigation_items(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
78 if not req.perm.has_permission('BUILD_VIEW'): |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
79 return |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
80 yield 'mainnav', 'build', \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
81 '<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
|
82 % 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
|
83 |
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
|
84 # 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
|
85 |
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
|
86 def match_request(self, req): |
184
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
87 match = re.match(r'/build(?:/([\w.-]+))?/?$', 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
|
88 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
|
89 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
90 req.args['config'] = match.group(1) |
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
|
91 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
|
92 |
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
|
93 def process_request(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
94 req.perm.assert_permission('BUILD_VIEW') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
95 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
96 action = req.args.get('action') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
97 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
98 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
99 if req.method == 'POST': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
100 if config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
101 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
102 self._do_create_platform(req, config) |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
103 elif action == 'delete': |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
104 self._do_delete_config(req, config) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
105 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
106 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
107 if platform_id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
108 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
109 self._do_save_platform(req, config, platform_id) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
110 elif 'delete' in req.args: |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
111 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
|
112 self._render_config_form(req, config) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
113 elif 'new' in req.args: |
96 | 114 platform = TargetPlatform(self.env, config=config) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
115 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
116 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
117 self._do_save_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
118 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
119 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
120 self._do_create_config(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
121 else: |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
122 if config: |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
123 if action == 'delete': |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
124 self._render_config_confirm(req, config) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
125 elif action == 'edit': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
126 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
127 if platform_id: |
96 | 128 platform = TargetPlatform.fetch(self.env, |
129 int(platform_id)) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
130 self._render_platform_form(req, platform) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
131 elif 'new' in req.args: |
96 | 132 platform = TargetPlatform(self.env, config=config) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
133 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
134 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
135 self._render_config_form(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
136 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
137 self._render_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
138 else: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
139 if action == 'new': |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
140 self._render_config_form(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
141 else: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
142 self._render_overview(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
143 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
144 add_stylesheet(req, 'bitten/bitten.css') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
145 return 'bitten_config.cs', None |
64 | 146 |
147 # Internal methods | |
148 | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
149 def _do_create_config(self, req): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
150 """Create a new build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
151 req.perm.assert_permission('BUILD_CREATE') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
152 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
153 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
154 req.redirect(self.env.href.build()) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
155 |
147
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
156 config_name = req.args.get('name') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
157 |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
158 assert not BuildConfig.fetch(self.env, config_name), \ |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
159 'A build configuration with the name "%s" already exists' \ |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
160 % config_name |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
161 |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
162 config = BuildConfig(self.env, name=config_name, |
96 | 163 path=req.args.get('path', ''), |
147
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
164 recipe=req.args.get('recipe', ''), |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
165 min_rev=req.args.get('min_rev', ''), |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
166 max_rev=req.args.get('max_rev', ''), |
96 | 167 label=req.args.get('label', ''), |
168 description=req.args.get('description')) | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
169 config.insert() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
170 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
171 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
|
172 |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
173 def _do_delete_config(self, req, config_name): |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
174 """Save changes to a build configuration.""" |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
175 req.perm.assert_permission('BUILD_DELETE') |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
176 |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
177 if 'cancel' in req.args: |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
178 req.redirect(self.env.href.build(config_name)) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
179 |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
180 config = BuildConfig.fetch(self.env, config_name) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
181 assert config, 'Build configuration "%s" does not exist' % config_name |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
182 |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
183 config.delete() |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
184 req.redirect(self.env.href.build()) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
185 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
186 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
|
187 """Save changes to a build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
188 req.perm.assert_permission('BUILD_MODIFY') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
189 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
190 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
191 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
|
192 |
96 | 193 config = BuildConfig.fetch(self.env, config_name) |
194 assert config, 'Build configuration "%s" does not exist' % config_name | |
147
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
195 |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
196 if 'activate' in req.args: |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
197 config.active = True |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
198 |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
199 elif 'deactivate' in req.args: |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
200 config.active = False |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
201 |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
202 else: |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
203 # TODO: Validate recipe, repository path, etc |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
204 config.name = req.args.get('name') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
205 config.path = req.args.get('path', '') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
206 config.recipe = req.args.get('recipe', '') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
207 config.min_rev = req.args.get('min_rev') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
208 config.max_rev = req.args.get('max_rev') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
209 config.label = req.args.get('label', '') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
210 config.description = req.args.get('description', '') |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
211 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
212 config.update() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
213 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
|
214 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
215 def _do_create_platform(self, req, config_name): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
216 """Create a new target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
217 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
218 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
219 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
220 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
221 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
222 platform = TargetPlatform(self.env, config=config_name) |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
223 if self._process_platform(req, platform): |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
224 platform.insert() |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
225 req.redirect(self.env.href.build(config_name, action='edit')) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
226 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
227 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
|
228 """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
|
229 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
|
230 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
|
231 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
232 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
|
233 for platform_id in [int(id) for id in req.args.get('delete_platform')]: |
96 | 234 platform = TargetPlatform.fetch(self.env, platform_id, db=db) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
235 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
|
236 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
|
237 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
|
238 db.commit() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
239 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
240 def _do_save_platform(self, req, config_name, platform_id): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
241 """Save changes to a target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
242 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
243 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
244 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
245 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
246 |
96 | 247 platform = TargetPlatform.fetch(self.env, platform_id) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
248 if self._process_platform(req, platform): |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
249 platform.update() |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
250 req.redirect(self.env.href.build(config_name, action='edit')) |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
251 |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
252 def _process_platform(self, req, platform): |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
253 platform.name = req.args.get('name') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
254 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
255 properties = [int(key[9:]) for key in req.args.keys() |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
256 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
257 properties.sort() |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
258 patterns = [int(key[8:]) for key in req.args.keys() |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
259 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
260 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
261 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
262 req.args.get('pattern_%d' % pattern)) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
263 for property, pattern in zip(properties, patterns) |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
264 if req.args.get('property_%d' % property)] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
265 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
266 add_rules = [int(key[9:]) for key in req.args.keys() |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
267 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
268 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
269 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
270 self._render_platform_form(req, platform) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
271 return False |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
272 rm_rules = [int(key[8:]) for key in req.args.keys() |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
273 if key.startswith('rm_rule_')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
274 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
275 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
276 self._render_platform_form(req, platform) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
277 return False |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
278 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
279 return True |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
280 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
281 def _render_overview(self, req): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
282 req.hdf['title'] = 'Build Status' |
45 | 283 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
|
284 for idx, config in enumerate(configurations): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
285 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
286 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
287 description = wiki_to_html(description, self.env, req) |
123 | 288 req.hdf['configs.%d' % idx] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
289 '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
|
290 'path': config.path, 'description': description, |
123 | 291 'href': self.env.href.build(config.name), |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
292 } |
123 | 293 req.hdf['page.mode'] = 'overview' |
294 req.hdf['config.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
|
295 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
296 def _render_config(self, req, config_name): |
96 | 297 config = BuildConfig.fetch(self.env, config_name) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
298 req.hdf['title'] = 'Build Configuration "%s"' \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
299 % escape(config.label or config.name) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
300 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
|
301 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
302 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
303 description = wiki_to_html(description, self.env, req) |
123 | 304 req.hdf['config'] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
305 '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
|
306 'active': config.active, 'description': description, |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
307 'browser_href': self.env.href.browser(config.path), |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
308 'can_modify': req.perm.has_permission('BUILD_MODIFY'), |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
309 'can_delete': req.perm.has_permission('BUILD_DELETE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
310 } |
123 | 311 req.hdf['page.mode'] = 'view_config' |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
312 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
313 platforms = TargetPlatform.select(self.env, config=config_name) |
123 | 314 req.hdf['config.platforms'] = [ |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
315 {'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
|
316 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
317 |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
318 store = get_store(self.env) |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
319 has_reports = False |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
320 for report in store.query('', config=config): |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
321 has_reports = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
322 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
323 |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
324 if has_reports: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
325 req.hdf['config.charts'] = [ |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
326 {'href': self.env.href.build(config.name, 'chart/unittest')}, |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
327 {'href': self.env.href.build(config.name, 'chart/trace')} |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
328 ] |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
329 charts_license = self.config.get('bitten', 'charts_license') |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
330 if charts_license: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
331 req.hdf['config.charts_license'] = escape(charts_license) |
178
fcbe107ca755
Add some basic charts to the build status page, based on [http://www.maani.us/xml_charts/index.php XML/SWF Charts]:
cmlenz
parents:
174
diff
changeset
|
332 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
333 repos = self.env.get_repository(req.authname) |
111
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
334 try: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
335 root = repos.get_node(config.path) |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
336 for idx, (path, rev, chg) in enumerate(root.get_history()): |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
337 # Don't follow moves/copies |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
338 if path != config.path: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
339 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
340 # If the directory was empty at that revision, it isn't built |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
341 old_node = repos.get_node(path, rev) |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
342 is_empty = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
343 for entry in old_node.get_entries(): |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
344 is_empty = False |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
345 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
346 if is_empty: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
347 continue |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
348 |
123 | 349 prefix = 'config.builds.%d' % rev |
111
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
350 req.hdf[prefix + '.href'] = self.env.href.changeset(rev) |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
351 for build in Build.select(self.env, config=config.name, rev=rev): |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
352 if build.status == Build.PENDING: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
353 continue |
181 | 354 build_hdf = _build_to_hdf(self.env, req, build) |
355 req.hdf['%s.%s' % (prefix, build.platform)] = build_hdf | |
178
fcbe107ca755
Add some basic charts to the build status page, based on [http://www.maani.us/xml_charts/index.php XML/SWF Charts]:
cmlenz
parents:
174
diff
changeset
|
356 if idx > 12: |
111
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
357 break |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
358 except TracError, e: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
359 self.log.error('Error accessing repository info', exc_info=True) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
360 |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
361 def _render_config_confirm(self, req, config_name): |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
362 req.perm.assert_permission('BUILD_DELETE') |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
363 config = BuildConfig.fetch(self.env, config_name) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
364 req.hdf['title'] = 'Delete Build Configuration "%s"' \ |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
365 % escape(config.label or config.name) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
366 req.hdf['config'] = {'name': config.name} |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
367 req.hdf['page.mode'] = 'delete_config' |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
368 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
369 def _render_config_form(self, req, config_name=None): |
96 | 370 config = BuildConfig.fetch(self.env, config_name) |
371 if config: | |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
372 req.perm.assert_permission('BUILD_MODIFY') |
123 | 373 req.hdf['config'] = { |
147
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
374 'name': config.name, 'exists': config.exists, |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
375 'path': config.path, 'active': config.active, |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
376 'recipe': config.recipe, 'min_rev': config.min_rev, |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
377 'max_rev': config.max_rev, 'label': config.label, |
395b67aa072e
Build recipes are now stored in the database with the build configuration. This means that it is no longer necessary to store the recipe in the repository. Closes #41.
cmlenz
parents:
142
diff
changeset
|
378 'description': config.description |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
379 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
380 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
381 req.hdf['title'] = 'Edit Build Configuration "%s"' \ |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
382 % escape(config.label or config.name) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
383 for idx, platform in enumerate(TargetPlatform.select(self.env, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
384 config_name)): |
123 | 385 req.hdf['config.platforms.%d' % idx] = { |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
386 'id': platform.id, 'name': platform.name, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
387 'href': self.env.href.build(config_name, action='edit', |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
388 platform=platform.id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
389 } |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
390 else: |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
391 req.perm.assert_permission('BUILD_CREATE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
392 req.hdf['title'] = 'Create Build Configuration' |
123 | 393 req.hdf['page.mode'] = 'edit_config' |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
394 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
395 def _render_platform_form(self, req, platform): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
396 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
|
397 if platform.exists: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
398 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
|
399 % escape(platform.name) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
400 else: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
401 req.hdf['title'] = 'Add Target Platform' |
123 | 402 req.hdf['platform'] = { |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
403 'name': platform.name, 'id': platform.id, 'exists': platform.exists, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
404 'rules': [{'property': propname, 'pattern': pattern} |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
405 for propname, pattern in platform.rules] or [('', '')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
406 } |
123 | 407 req.hdf['page.mode'] = 'edit_platform' |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
408 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
409 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
410 class BuildController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
411 """Renders the build page.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
412 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
413 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
414 log_formatters = ExtensionPoint(ILogFormatter) |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
415 report_summarizers = ExtensionPoint(IReportSummarizer) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
416 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
417 # INavigationContributor methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
418 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
419 def get_active_navigation_item(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
420 return 'build' |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
421 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
422 def get_navigation_items(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
423 return [] |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
424 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
425 # IRequestHandler methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
426 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
427 def match_request(self, req): |
174
79c61c26a4e1
* Changed the `IReportStore` interface to allow querying with [http://www.w3.org/XML/Query/ XQuery]. This should make it possible to efficiently query the report store for any existing metrics.
cmlenz
parents:
168
diff
changeset
|
428 match = re.match(r'/build/([\w.-]+)/(\d+)', req.path_info) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
429 if match: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
430 if match.group(1): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
431 req.args['config'] = match.group(1) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
432 if match.group(2): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
433 req.args['id'] = match.group(2) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
434 return True |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
435 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
436 def process_request(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
437 req.perm.assert_permission('BUILD_VIEW') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
438 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
439 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
440 build_id = int(req.args.get('id')) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
441 build = Build.fetch(self.env, build_id, db=db) |
96 | 442 assert build, 'Build %s does not exist' % build_id |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
443 |
184
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
444 if req.method == 'POST': |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
445 if req.args.get('action') == 'invalidate': |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
446 self._do_invalidate(req, build, db) |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
447 req.redirect(self.env.href.build(build.config, build.id)) |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
448 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
449 add_link(req, 'up', self.env.href.build(build.config), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
450 'Build Configuration') |
91 | 451 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', |
452 Build.IN_PROGRESS: 'In Progress'} | |
69 | 453 req.hdf['title'] = 'Build %s - %s' % (build_id, |
454 status2title[build.status]) | |
123 | 455 req.hdf['page.mode'] = 'view_build' |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
456 config = BuildConfig.fetch(self.env, build.config, db=db) |
69 | 457 req.hdf['build.config'] = { |
458 'name': config.label, | |
459 'href': self.env.href.build(config.name) | |
460 } | |
461 | |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
462 req.hdf['build'] = _build_to_hdf(self.env, req, build) |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
463 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
464 for step in BuildStep.select(self.env, build=build.id, db=db): |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
465 steps.append({ |
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
466 'name': step.name, 'description': step.description, |
123 | 467 'duration': pretty_timedelta(step.started, step.stopped), |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
468 'failed': step.status == BuildStep.FAILURE, |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
469 'log': self._render_log(req, build, step), |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
470 'reports': self._render_reports(req, build, step) |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
471 }) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
472 req.hdf['build.steps'] = steps |
184
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
473 req.hdf['build.can_delete'] = req.perm.has_permission('BUILD_DELETE') |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
474 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
475 add_stylesheet(req, 'bitten/bitten.css') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
476 return 'bitten_build.cs', None |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
477 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
478 # ITimelineEventProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
479 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
480 def get_timeline_filters(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
481 if req.perm.has_permission('BUILD_VIEW'): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
482 yield ('build', 'Builds') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
483 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
484 def get_timeline_events(self, req, start, stop, filters): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
485 if 'build' in filters: |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
486 add_stylesheet(req, 'bitten/bitten.css') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
487 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
488 cursor = db.cursor() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
489 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name,b.slave," |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
490 "b.stopped,b.status FROM bitten_build AS b" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
491 " INNER JOIN bitten_config AS c ON (c.name=b.config)" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
492 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
493 "WHERE b.stopped>=%s AND b.stopped<=%s " |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
494 "AND b.status IN (%s, %s) ORDER BY b.stopped", |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
495 (start, stop, Build.SUCCESS, Build.FAILURE)) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
496 event_kinds = {Build.SUCCESS: 'successbuild', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
497 Build.FAILURE: 'failedbuild'} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
498 for id, config, label, rev, platform, slave, stopped, status in cursor: |
168
565f8b5126f8
Drop the slave name from the timeline events summary.
cmlenz
parents:
165
diff
changeset
|
499 title = 'Build of <em>%s [%s]</em> on %s %s' \ |
565f8b5126f8
Drop the slave name from the timeline events summary.
cmlenz
parents:
165
diff
changeset
|
500 % (escape(label), escape(rev), escape(platform), |
565f8b5126f8
Drop the slave name from the timeline events summary.
cmlenz
parents:
165
diff
changeset
|
501 _status_label[status]) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
502 if req.args.get('format') == 'rss': |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
503 href = self.env.abs_href.build(config, id) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
504 else: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
505 href = self.env.href.build(config, id) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
506 yield event_kinds[status], href, title, stopped, None, '' |
114
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
507 |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
508 # Internal methods |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
509 |
184
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
510 def _do_invalidate(self, req, build, db): |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
511 self.log.info('Invalidating build %d', build.id) |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
512 |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
513 for step in BuildStep.select(self.env, build=build.id, db=db): |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
514 step.delete(db=db) |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
515 |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
516 store = get_store(self.env) |
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
517 store.delete(build=build) |
184
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
518 |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
519 build.slave = None |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
520 build.started = build.stopped = 0 |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
521 build.status = Build.PENDING |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
522 build.slave_info = {} |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
523 build.update() |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
524 |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
525 db.commit() |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
526 |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
527 req.redirect(self.env.href.build(build.config)) |
fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
cmlenz
parents:
182
diff
changeset
|
528 |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
529 def _render_log(self, req, build, step): |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
530 items = [] |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
531 for log in BuildLog.select(self.env, build=build.id, step=step.name): |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
532 formatters = [] |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
533 for formatter in self.log_formatters: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
534 formatters.append(formatter.get_formatter(req, build, step, |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
535 log.type)) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
536 for level, message in log.messages: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
537 for format in formatters: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
538 message = format(level, message) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
539 items.append({'level': level, 'message': message}) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
540 return items |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
541 |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
542 def _render_reports(self, req, build, step): |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
543 summarizers = {} # keyed by report type |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
544 for summarizer in self.report_summarizers: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
545 types = summarizer.get_supported_report_types() |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
546 summarizers.update(dict([(type, summarizer) for type in types])) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
547 |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
548 store = get_store(self.env) |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
549 reports = [] |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
550 for report in store.retrieve(build, step): |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
551 report_type = report.attr['type'] |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
552 summarizer = summarizers.get(report_type) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
553 if summarizer: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
554 summary = summarizer.render_report_summary(req, build, step, |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
555 report) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
556 else: |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
557 summary = None |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
558 report_href = self.env.href.buildreport(build.id, step.name, |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
559 report_type) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
560 reports.append({'type': report_type, 'href': report_href, |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
561 'summary': summary}) |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
562 return reports |
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
563 |
114
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
564 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
565 class SourceFileLinkFormatter(Component): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
566 """Finds references to files and directories in the repository in the build |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
567 log and renders them as links to the repository browser.""" |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
568 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
569 implements(ILogFormatter) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
570 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
571 def get_formatter(self, req, build, step, type): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
572 config = BuildConfig.fetch(self.env, build.config) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
573 repos = self.env.get_repository(req.authname) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
574 nodes = [] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
575 def _walk(node): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
576 for child in node.get_entries(): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
577 path = child.path[len(config.path) + 1:] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
578 pattern = re.compile("([\s'\"])(%s)([\s'\"])" % re.escape(path)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
579 nodes.append((child.path, pattern)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
580 if child.isdir: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
581 _walk(child) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
582 _walk(repos.get_node(config.path, build.rev)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
583 nodes.sort(lambda x, y: -cmp(len(x[0]), len(y[0]))) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
584 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
585 def _formatter(level, message): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
586 for path, pattern in nodes: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
587 def _replace(m): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
588 return '%s<a href="%s">%s</a>%s' % (m.group(1), |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
589 self.env.href.browser(path, rev=build.rev), |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
590 m.group(2), m.group(3)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
591 message = pattern.sub(_replace, message) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
592 return message |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
593 return _formatter |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
594 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
595 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
596 class BuildReportController(Component): |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
597 """Temporary web interface that simply displays the XML source of a report |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
598 using the Trac `Mimeview` component.""" |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
599 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
600 implements(INavigationContributor, IRequestHandler) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
601 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
602 template_cs = """<?cs include:"header.cs" ?> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
603 <div id="ctxtnav" class="nav"></div> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
604 <div id="content" class="build"> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
605 <h1>Build <a href="<?cs var:build.href ?>"><?cs var:build.id ?></a>: <?cs |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
606 var:report.type ?></h1> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
607 <?cs var:report.preview ?> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
608 </div> |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
609 <?cs include:"footer.cs" ?>""" |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
610 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
611 # INavigationContributor methods |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
612 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
613 def get_active_navigation_item(self, req): |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
614 return 'build' |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
615 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
616 def get_navigation_items(self, req): |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
617 return [] |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
618 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
619 # IRequestHandler methods |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
620 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
621 def match_request(self, req): |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
622 match = re.match(r'/buildreport/(?P<build>[\d]+)/(?P<step>[\w]+)' |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
623 r'/(?P<type>[\w]+)', req.path_info) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
624 if match: |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
625 for name in match.groupdict(): |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
626 req.args[name] = match.group(name) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
627 return True |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
628 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
629 def process_request(self, req): |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
630 req.perm.assert_permission('BUILD_VIEW') |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
631 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
632 build = Build.fetch(self.env, int(req.args.get('build'))) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
633 if not build: |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
634 raise TracError, 'Build %d does not exist' % req.args.get('build') |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
635 step = BuildStep.fetch(self.env, build.id, req.args.get('step')) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
636 if not step: |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
637 raise TracError, 'Build step %s does not exist' \ |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
638 % req.args.get('step') |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
639 report_type = req.args.get('type') |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
640 |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
641 req.hdf['build'] = {'id': build.id, |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
642 'href': self.env.href.build(build.config, build.id)} |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
643 |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
644 store = get_store(self.env) |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
645 reports = [] |
196
b5f7d8a4035e
In preparation for supporting BDB XML transactions, move the report store backend selection away from using Trac extension points, and use a plain Python object instead of a component to represent a store backend.
cmlenz
parents:
195
diff
changeset
|
646 for report in store.retrieve(build, step, report_type): |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
647 req.hdf['title'] = 'Build %d: %s' % (build.id, report_type) |
138 | 648 xml = report._node.toprettyxml(' ') |
649 if req.args.get('format') == 'xml': | |
650 req.send_response(200) | |
651 req.send_header('Content-Type', 'text/xml;charset=utf-8') | |
652 req.end_headers() | |
653 req.write(xml) | |
654 return | |
655 else: | |
656 from trac.mimeview import Mimeview | |
657 preview = Mimeview(self.env).render(req, 'application/xml', xml) | |
658 req.hdf['report'] = {'type': report_type, 'preview': preview} | |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
659 break |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
660 |
138 | 661 xml_href = self.env.href.buildreport(build.id, step.name, report_type, |
662 format='xml') | |
663 add_link(req, 'alternate', xml_href, 'XML', 'text/xml') | |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
664 add_stylesheet(req, 'common/css/code.css') |
128
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
665 template = req.hdf.parse(self.template_cs) |
4e3373472318
Add a view of the XML reports stored for a build. This is temporary, and will probably go away as soon as a proper interface to the reports is added.
cmlenz
parents:
123
diff
changeset
|
666 return template, None |