Mercurial > bitten > bitten-test
annotate bitten/trac_ext/web_ui.py @ 311:7f6fc38e14ff
More assertions in `Build` model methods.
author | cmlenz |
---|---|
date | Wed, 23 Nov 2005 11:19:24 +0000 |
parents | 5f84af72d17f |
children | 87c9b1e8f086 |
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 |
295
5f84af72d17f
* Store executable bit in ZIP archives (from `svn:executable`).
cmlenz
parents:
263
diff
changeset
|
10 from datetime import datetime |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
11 import posixpath |
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 import re |
250 | 13 try: |
14 set | |
15 except NameError: | |
16 from sets import Set as set | |
17 from StringIO import StringIO | |
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
|
18 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
19 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
|
20 from trac.core import * |
64 | 21 from trac.Timeline import ITimelineEventProvider |
295
5f84af72d17f
* Store executable bit in ZIP archives (from `svn:executable`).
cmlenz
parents:
263
diff
changeset
|
22 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line |
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
|
23 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
|
24 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
|
25 add_link, add_stylesheet |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
26 from trac.wiki import wiki_to_html, wiki_to_oneliner |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
27 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, \ |
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
28 BuildLog, Report |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
29 from bitten.queue import collect_changes |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
30 from bitten.recipe import Recipe, InvalidRecipeError |
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
|
31 from bitten.trac_ext.api import ILogFormatter, IReportSummarizer |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
32 from bitten.util import xmlio |
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
|
33 |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
34 _status_label = {Build.PENDING: 'pending', |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
35 Build.IN_PROGRESS: 'in progress', |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
36 Build.SUCCESS: 'completed', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
37 Build.FAILURE: 'failed'} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
38 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
39 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
|
40 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
|
41 'status': _status_label[build.status], |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
42 'cls': _status_label[build.status].replace(' ', '-'), |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
43 '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
|
44 '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
|
45 if build.started: |
250 | 46 hdf['started'] = format_datetime(build.started) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
47 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
|
48 if build.stopped: |
250 | 49 hdf['stopped'] = format_datetime(build.stopped) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
50 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
|
51 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
|
52 hdf['slave'] = { |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
53 'name': build.slave, |
250 | 54 'ipnr': build.slave_info.get(Build.IP_ADDRESS), |
55 'os.name': build.slave_info.get(Build.OS_NAME), | |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
56 '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
|
57 '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
|
58 '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
|
59 '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
|
60 } |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
61 return hdf |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
62 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
63 class BittenChrome(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
64 """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
|
65 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
66 implements(ITemplateProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
67 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
68 # ITemplatesProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
69 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
70 def get_htdocs_dirs(self): |
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
71 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
|
72 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
73 def get_templates_dirs(self): |
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
74 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
|
75 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
76 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
77 class BuildConfigController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
78 """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
|
79 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
80 implements(INavigationContributor, IRequestHandler) |
64 | 81 |
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
|
82 # 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
|
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 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
|
85 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
|
86 |
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
|
87 def get_navigation_items(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
88 if not req.perm.has_permission('BUILD_VIEW'): |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
89 return |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
90 yield 'mainnav', 'build', \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
91 '<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
|
92 % 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
|
93 |
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
|
94 # 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
|
95 |
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
|
96 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
|
97 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
|
98 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
|
99 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
100 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
|
101 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
|
102 |
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
|
103 def process_request(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
104 req.perm.assert_permission('BUILD_VIEW') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
105 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
106 action = req.args.get('action') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
107 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
108 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
109 if req.method == 'POST': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
110 if config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
111 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
112 self._do_create_platform(req, config) |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
113 elif action == 'delete': |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
114 self._do_delete_config(req, config) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
115 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
116 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
117 if platform_id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
118 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 self._render_config_form(req, config) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
123 elif 'new' in req.args: |
96 | 124 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
|
125 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
126 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
127 self._do_save_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
128 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
129 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
130 self._do_create_config(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
131 else: |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
132 if config: |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
133 if action == 'delete': |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
134 self._render_config_confirm(req, config) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
135 elif action == 'edit': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
136 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
137 if platform_id: |
96 | 138 platform = TargetPlatform.fetch(self.env, |
139 int(platform_id)) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
140 self._render_platform_form(req, platform) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
141 elif 'new' in req.args: |
96 | 142 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
|
143 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
144 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
145 self._render_config_form(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
146 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
147 self._render_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
148 else: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
149 if action == 'new': |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
150 self._render_config_form(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
151 else: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
152 self._render_overview(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
153 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
154 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
|
155 return 'bitten_config.cs', None |
64 | 156 |
157 # Internal methods | |
158 | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
159 def _do_create_config(self, req): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
160 """Create a new build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
161 req.perm.assert_permission('BUILD_CREATE') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
162 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
163 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
164 req.redirect(self.env.href.build()) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
165 |
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
|
166 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
|
167 |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
168 if BuildConfig.fetch(self.env, config_name): |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
169 raise TracError('A build configuration with the name "%s" already ' |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
170 'exists' % config_name, 'Duplicate 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
|
171 |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
172 config = BuildConfig(self.env) |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
173 self._process_config(req, config) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
174 config.insert() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
175 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
176 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
|
177 |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
178 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
|
179 """Save changes to a build configuration.""" |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
180 req.perm.assert_permission('BUILD_DELETE') |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
181 |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
182 if 'cancel' in req.args: |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
183 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
|
184 |
200
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
185 db = self.env.get_db_cnx() |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
186 |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
187 config = BuildConfig.fetch(self.env, config_name, db=db) |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
188 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
|
189 |
200
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
190 config.delete(db=db) |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
191 |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
192 db.commit() |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
193 |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
194 req.redirect(self.env.href.build()) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
195 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
196 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
|
197 """Save changes to a build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
198 req.perm.assert_permission('BUILD_MODIFY') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
199 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
200 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
201 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
|
202 |
96 | 203 config = BuildConfig.fetch(self.env, config_name) |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
204 if not config: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
205 # FIXME: 404 |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
206 raise TracError('Build configuration "%s" does not exist' |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
207 % config_name, 'Object not found') |
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
|
208 |
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 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
|
210 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
|
211 |
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
|
212 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
|
213 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
|
214 |
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
|
215 else: |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
216 self._process_config(req, 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
|
217 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
218 config.update() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
219 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
|
220 |
247
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
221 def _process_config(self, req, config): |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
222 if not req.args.get('name'): |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
223 raise TracError('Missing required field "name"', 'Missing field') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
224 |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
225 path = req.args.get('path', '') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
226 repos = self.env.get_repository(req.authname) |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
227 max_rev = req.args.get('max_rev') or None |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
228 try: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
229 node = repos.get_node(path, max_rev) |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
230 assert node.isdir, '%s is not a directory' % node.path |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
231 except (AssertionError, TracError), e: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
232 raise TracError(e, 'Invalid repository path') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
233 if req.args.get('min_rev'): |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
234 try: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
235 repos.get_node(path, req.args.get('min_rev')) |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
236 except TracError, e: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
237 raise TracError(e, 'Invalid value for oldest revision') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
238 |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
239 recipe_xml = req.args.get('recipe', '') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
240 if recipe_xml: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
241 try: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
242 Recipe(xmlio.parse(recipe_xml)).validate() |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
243 except xmlio.ParseError, e: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
244 raise TracError('Failure parsing recipe: %s' % e, |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
245 'Invalid recipe') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
246 except InvalidRecipeError, e: |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
247 raise TracError(e, 'Invalid recipe') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
248 |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
249 config.name = req.args.get('name') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
250 config.path = repos.normalize_path(path) |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
251 config.recipe = recipe_xml |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
252 config.min_rev = req.args.get('min_rev') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
253 config.max_rev = req.args.get('max_rev') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
254 config.label = req.args.get('label', '') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
255 config.description = req.args.get('description', '') |
b28285d3ceec
Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents:
245
diff
changeset
|
256 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
257 def _do_create_platform(self, req, config_name): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
258 """Create a new target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
259 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
260 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
261 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
262 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
263 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
264 platform = TargetPlatform(self.env, config=config_name) |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
265 if self._process_platform(req, platform): |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
266 platform.insert() |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
267 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
|
268 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
269 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
|
270 """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
|
271 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
|
272 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
|
273 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
274 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
|
275 for platform_id in [int(id) for id in req.args.get('delete_platform')]: |
96 | 276 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
|
277 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
|
278 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
|
279 platform.delete(db=db) |
200
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
280 |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
281 # FIXME: this should probably also delete all builds done for this |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
282 # platform, and all the associated reports |
692924ffed80
Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents:
198
diff
changeset
|
283 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
284 db.commit() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
285 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
286 def _do_save_platform(self, req, config_name, platform_id): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
287 """Save changes to a target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
288 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
289 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
290 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
291 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
292 |
96 | 293 platform = TargetPlatform.fetch(self.env, platform_id) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
294 if self._process_platform(req, platform): |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
295 platform.update() |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
296 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
|
297 |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
298 def _process_platform(self, req, platform): |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
299 platform.name = req.args.get('name') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
300 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
301 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
|
302 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
303 properties.sort() |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
304 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
|
305 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
306 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
307 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
308 req.args.get('pattern_%d' % pattern)) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
309 for property, pattern in zip(properties, patterns) |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
310 if req.args.get('property_%d' % property)] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
311 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
312 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
|
313 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
314 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
315 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
316 self._render_platform_form(req, platform) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
317 return False |
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
318 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
|
319 if key.startswith('rm_rule_')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
320 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
321 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
322 self._render_platform_form(req, platform) |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
323 return False |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
324 |
192
da2a2e9a8f71
Fix target platform management under mod_python. Closes #44.
cmlenz
parents:
184
diff
changeset
|
325 return True |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
326 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
327 def _render_overview(self, req): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
328 req.hdf['title'] = 'Build Status' |
209
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
329 show_all = False |
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
330 if req.args.get('show') == 'all': |
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
331 show_all = True |
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
332 req.hdf['config.show_all'] = show_all |
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
333 |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
334 configs = BuildConfig.select(self.env, include_inactive=show_all) |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
335 for idx, config in enumerate(configs): |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
336 prefix = 'configs.%d' % idx |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
337 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
338 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
339 description = wiki_to_html(description, self.env, req) |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
340 req.hdf[prefix] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
341 'name': config.name, 'label': config.label or config.name, |
209
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
342 'active': config.active, 'path': config.path, |
d2b9c72e9643
Hide deactivated build configurations on the build status page by default, and provide an option panel to make them visible.
cmlenz
parents:
203
diff
changeset
|
343 'description': description, |
123 | 344 '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
|
345 } |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
346 if not config.active: |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
347 continue |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
348 |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
349 repos = self.env.get_repository(req.authname) |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
350 repos.sync() |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
351 prev_rev = None |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
352 for platform, rev, build in collect_changes(repos, config): |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
353 if rev != prev_rev: |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
354 if prev_rev is None: |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
355 chgset = repos.get_changeset(rev) |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
356 req.hdf[prefix + '.youngest_rev'] = { |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
357 'id': rev, 'href': self.env.href.changeset(rev), |
262 | 358 'author': escape(chgset.author) or 'anonymous', |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
359 'date': format_datetime(chgset.date), |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
360 'message': wiki_to_oneliner( |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
361 shorten_line(chgset.message), self.env) |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
362 } |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
363 else: |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
364 break |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
365 prev_rev = rev |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
366 if build: |
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
367 build_hdf = _build_to_hdf(self.env, req, build) |
256
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
368 build_hdf['platform'] = escape(platform.name) |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
369 req.hdf[prefix + '.builds.%d' % platform.id] = build_hdf |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
370 else: |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
371 req.hdf[prefix + '.builds.%d' % platform.id] = { |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
372 'platform': escape(platform.name), 'status': 'pending' |
aa942e2c7243
A bit of polishing for [265]: also show build if not yet in the queue, some layout improvements.
cmlenz
parents:
255
diff
changeset
|
373 } |
255
42f555e1d648
Show the build status for the latest changeset for every build configuration on the main build status page. Closes #21.
cmlenz
parents:
250
diff
changeset
|
374 |
123 | 375 req.hdf['page.mode'] = 'overview' |
376 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
|
377 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
378 def _render_config(self, req, config_name): |
250 | 379 db = self.env.get_db_cnx() |
380 | |
381 config = BuildConfig.fetch(self.env, config_name, db=db) | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
382 req.hdf['title'] = 'Build Configuration "%s"' \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
383 % escape(config.label or config.name) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
384 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
|
385 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
386 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
387 description = wiki_to_html(description, self.env, req) |
123 | 388 req.hdf['config'] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
389 'name': config.name, 'label': config.label, 'path': config.path, |
250 | 390 'min_rev': config.min_rev, |
391 'min_rev_href': self.env.href.changeset(config.min_rev), | |
392 'max_rev': config.max_rev, | |
393 'max_rev_href': self.env.href.changeset(config.max_rev), | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
394 'active': config.active, 'description': description, |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
395 '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
|
396 '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
|
397 '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
|
398 } |
123 | 399 req.hdf['page.mode'] = 'view_config' |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
400 |
250 | 401 platforms = list(TargetPlatform.select(self.env, config=config_name, |
402 db=db)) | |
123 | 403 req.hdf['config.platforms'] = [ |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
404 {'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
|
405 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
406 |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
407 has_reports = False |
250 | 408 for report in Report.select(self.env, config=config.name, db=db): |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
409 has_reports = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
410 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
411 |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
412 if has_reports: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
413 req.hdf['config.charts'] = [ |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
414 {'href': self.env.href.build(config.name, 'chart/test')}, |
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
415 {'href': self.env.href.build(config.name, 'chart/coverage')} |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
416 ] |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
417 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
|
418 if charts_license: |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
419 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
|
420 |
214 | 421 page = max(1, int(req.args.get('page', 1))) |
422 more = False | |
423 req.hdf['page.number'] = page | |
424 | |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
425 builds_per_page = 12 * len(platforms) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
426 repos = self.env.get_repository(req.authname) |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
427 repos.sync() |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
428 idx = 0 |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
429 for platform, rev, build in collect_changes(repos, config): |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
430 if idx >= page * builds_per_page: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
431 more = True |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
432 break |
232
b6e4896dc026
Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents:
230
diff
changeset
|
433 elif idx >= (page - 1) * builds_per_page: |
230 | 434 prefix = 'config.builds.%d' % rev |
435 req.hdf[prefix + '.href'] = self.env.href.changeset(rev) | |
436 if build and build.status != Build.PENDING: | |
437 build_hdf = _build_to_hdf(self.env, req, build) | |
438 req.hdf['%s.%s' % (prefix, platform.id)] = build_hdf | |
250 | 439 for step in BuildStep.select(self.env, build=build.id, |
440 db=db): | |
441 req.hdf['%s.%s.steps.%s' % (prefix, platform.id, | |
442 step.name)] = { | |
443 'description': escape(step.description), | |
444 'duration': datetime.fromtimestamp(step.stopped) - \ | |
445 datetime.fromtimestamp(step.started), | |
446 'failed': not step.successful, | |
447 'errors': step.errors, | |
448 'href': build_hdf['href'] + '#step_' + step.name, | |
449 } | |
230 | 450 idx += 1 |
214 | 451 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
452 if page > 1: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
453 if page == 2: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
454 prev_href = self.env.href.build(config.name) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
455 else: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
456 prev_href = self.env.href.build(config.name, page=page - 1) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
457 add_link(req, 'prev', prev_href, 'Previous Page') |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
458 if more: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
459 next_href = self.env.href.build(config.name, page=page + 1) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
460 add_link(req, 'next', next_href, 'Next Page') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
461 |
195
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
462 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
|
463 req.perm.assert_permission('BUILD_DELETE') |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
464 config = BuildConfig.fetch(self.env, config_name) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
465 req.hdf['title'] = 'Delete Build Configuration "%s"' \ |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
466 % escape(config.label or config.name) |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
467 req.hdf['config'] = {'name': config.name} |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
468 req.hdf['page.mode'] = 'delete_config' |
bd6234ed6ac5
Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents:
192
diff
changeset
|
469 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
470 def _render_config_form(self, req, config_name=None): |
96 | 471 config = BuildConfig.fetch(self.env, config_name) |
472 if config: | |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
473 req.perm.assert_permission('BUILD_MODIFY') |
123 | 474 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
|
475 '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
|
476 '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
|
477 '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
|
478 '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
|
479 'description': config.description |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
480 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
481 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
482 req.hdf['title'] = 'Edit Build Configuration "%s"' \ |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
483 % escape(config.label or config.name) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
484 for idx, platform in enumerate(TargetPlatform.select(self.env, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
485 config_name)): |
123 | 486 req.hdf['config.platforms.%d' % idx] = { |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
487 'id': platform.id, 'name': platform.name, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
488 'href': self.env.href.build(config_name, action='edit', |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
489 platform=platform.id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
490 } |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
491 else: |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
492 req.perm.assert_permission('BUILD_CREATE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
493 req.hdf['title'] = 'Create Build Configuration' |
123 | 494 req.hdf['page.mode'] = 'edit_config' |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
495 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
496 def _render_platform_form(self, req, platform): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
497 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
|
498 if platform.exists: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
499 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
|
500 % escape(platform.name) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
501 else: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
502 req.hdf['title'] = 'Add Target Platform' |
123 | 503 req.hdf['platform'] = { |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
504 'name': platform.name, 'id': platform.id, 'exists': platform.exists, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
505 '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
|
506 for propname, pattern in platform.rules] or [('', '')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
507 } |
123 | 508 req.hdf['page.mode'] = 'edit_platform' |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
509 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
510 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
511 class BuildController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
512 """Renders the build page.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
513 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
514 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
515 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
|
516 report_summarizers = ExtensionPoint(IReportSummarizer) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
517 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
518 # INavigationContributor methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
519 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
520 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
|
521 return 'build' |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
522 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
523 def get_navigation_items(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
524 return [] |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
525 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
526 # IRequestHandler methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
527 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
528 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
|
529 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
|
530 if match: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
531 if match.group(1): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
532 req.args['config'] = match.group(1) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
533 if match.group(2): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
534 req.args['id'] = match.group(2) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
535 return True |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
536 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
537 def process_request(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
538 req.perm.assert_permission('BUILD_VIEW') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
539 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
540 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
541 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
|
542 build = Build.fetch(self.env, build_id, db=db) |
96 | 543 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
|
544 |
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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
550 add_link(req, 'up', self.env.href.build(build.config), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
551 'Build Configuration') |
91 | 552 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', |
553 Build.IN_PROGRESS: 'In Progress'} | |
69 | 554 req.hdf['title'] = 'Build %s - %s' % (build_id, |
555 status2title[build.status]) | |
123 | 556 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
|
557 config = BuildConfig.fetch(self.env, build.config, db=db) |
69 | 558 req.hdf['build.config'] = { |
559 'name': config.label, | |
560 'href': self.env.href.build(config.name) | |
561 } | |
562 | |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
563 formatters = [] |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
564 for formatter in self.log_formatters: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
565 formatters.append(formatter.get_formatter(req, build)) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
566 |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
567 summarizers = {} # keyed by report type |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
568 for summarizer in self.report_summarizers: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
569 categories = summarizer.get_supported_categories() |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
570 summarizers.update(dict([(cat, summarizer) for cat in categories])) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
571 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
572 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
|
573 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
574 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
|
575 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
|
576 'name': step.name, 'description': step.description, |
123 | 577 '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
|
578 'failed': step.status == BuildStep.FAILURE, |
245
a22ec8fce6c9
Store the reason(s) for build step failure in the database.
cmlenz
parents:
232
diff
changeset
|
579 'errors': step.errors, |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
580 'log': self._render_log(req, build, formatters, step), |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
581 'reports': self._render_reports(req, config, build, summarizers, |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
582 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
|
583 }) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
584 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
|
585 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
|
586 |
250 | 587 repos = self.env.get_repository(req.authname) |
588 chgset = repos.get_changeset(build.rev) | |
589 req.hdf['build.chgset_author'] = chgset.author | |
590 | |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
591 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
|
592 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
|
593 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
594 # ITimelineEventProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
595 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
596 def get_timeline_filters(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
597 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
|
598 yield ('build', 'Builds') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
599 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
600 def get_timeline_events(self, req, start, stop, filters): |
311 | 601 if 'build' not in filters: |
602 return | |
250 | 603 |
311 | 604 add_stylesheet(req, 'bitten/bitten.css') |
605 | |
606 db = self.env.get_db_cnx() | |
607 cursor = db.cursor() | |
608 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name," | |
609 "b.stopped,b.status FROM bitten_build AS b" | |
610 " INNER JOIN bitten_config AS c ON (c.name=b.config) " | |
611 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " | |
612 "WHERE b.stopped>=%s AND b.stopped<=%s " | |
613 "AND b.status IN (%s, %s) ORDER BY b.stopped", | |
614 (start, stop, Build.SUCCESS, Build.FAILURE)) | |
615 | |
616 event_kinds = {Build.SUCCESS: 'successbuild', | |
617 Build.FAILURE: 'failedbuild'} | |
618 for id, config, label, rev, platform, stopped, status in cursor: | |
619 | |
620 errors = [] | |
621 if status == Build.FAILURE: | |
622 for step in BuildStep.select(self.env, build=id, | |
623 status=BuildStep.FAILURE, | |
624 db=db): | |
625 errors += [(escape(step.name), escape(error)) for error | |
626 in step.errors] | |
627 | |
628 title = 'Build of <em>%s [%s]</em> on %s %s' \ | |
629 % (escape(label), escape(rev), escape(platform), | |
630 _status_label[status]) | |
631 message = '' | |
632 if req.args.get('format') == 'rss': | |
633 href = self.env.abs_href.build(config, id) | |
634 if errors: | |
635 buf = StringIO() | |
636 prev_step = None | |
637 for step, error in errors: | |
638 if step != prev_step: | |
639 if prev_step is not None: | |
640 buf.write('</ul>') | |
641 buf.write('<p>Step %s failed:</p><ul>' % step) | |
642 prev_step = step | |
643 buf.write('<li>%s</li>' % escape(error)) | |
644 buf.write('</ul>') | |
645 message = buf.getvalue() | |
646 else: | |
647 href = self.env.href.build(config, id) | |
648 if errors: | |
649 steps = [] | |
650 for step, error in errors: | |
651 if step not in steps: | |
652 steps.append(step) | |
653 steps = ['<em>%s</em>' % step for step in steps] | |
654 if len(steps) < 2: | |
655 message = steps[0] | |
656 elif len(steps) == 2: | |
657 message = ' and '.join(steps) | |
658 elif len(steps) > 2: | |
659 message = ', '.join(steps[:-1]) + ', and ' + \ | |
660 steps[-1] | |
661 message = 'Step%s ' % (len(steps) != 1 and 's' or '') \ | |
662 + message + ' failed' | |
663 yield event_kinds[status], href, title, stopped, None, message | |
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
|
664 |
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
|
665 # 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
|
666 |
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
|
667 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
|
668 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
|
669 |
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
|
670 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
|
671 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
|
672 |
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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 |
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
|
679 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
|
680 |
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
|
681 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
|
682 |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
683 def _render_log(self, req, build, formatters, 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
|
684 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
|
685 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
|
686 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
|
687 for format in formatters: |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
688 message = format(step, log.generator, level, message) |
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
|
689 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
|
690 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
|
691 |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
692 def _render_reports(self, req, config, build, summarizers, 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
|
693 reports = [] |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
694 for report in Report.select(self.env, build=build.id, step=step.name): |
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
695 summarizer = summarizers.get(report.category) |
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
|
696 if summarizer: |
213
25f84dd9f159
* Refactoring of build recipes, the file format has changed slightly:
cmlenz
parents:
209
diff
changeset
|
697 summary = summarizer.render_summary(req, config, build, step, |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
698 report.category) |
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
|
699 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
|
700 summary = None |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
701 reports.append({'category': report.category, 'summary': summary}) |
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
|
702 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
|
703 |
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
|
704 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
705 class SourceFileLinkFormatter(Component): |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
706 """Detects references to files in the build log and renders them as links |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
707 to the repository browser.""" |
203
e6ddca1e5712
Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents:
200
diff
changeset
|
708 |
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
|
709 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
|
710 |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
711 _fileref_re = re.compile('(?P<path>[\w.-]+(?:/[\w.-]+)+)(?P<line>(:\d+))') |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
712 |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
713 def get_formatter(self, req, build): |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
714 """Return the log message formatter function.""" |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
715 config = BuildConfig.fetch(self.env, name=build.config) |
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
|
716 repos = self.env.get_repository(req.authname) |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
717 href = self.env.href.browser |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
718 cache = {} |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
719 def _replace(m): |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
720 filepath = posixpath.normpath(m.group('path').replace('\\', '/')) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
721 if not cache.get(filepath) is True: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
722 parts = filepath.split('/') |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
723 path = '' |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
724 for part in parts: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
725 path = posixpath.join(path, part) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
726 if not path in cache: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
727 try: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
728 repos.get_node(posixpath.join(config.path, path), |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
729 build.rev) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
730 cache[path] = True |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
731 except TracError: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
732 cache[path] = False |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
733 if cache[path] is False: |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
734 return m.group(0) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
735 return '<a href="%s">%s</a>' % ( |
263 | 736 href(config.path, filepath) + '#L' + m.group('line')[1:], |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
737 m.group(0)) |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
738 def _formatter(step, type, level, message): |
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
739 return self._fileref_re.sub(_replace, message) |
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
|
740 return _formatter |