annotate bitten/trac_ext/web_ui.py @ 409:5786700df0c7

Moved/restructured the modules implementing report chart generators and report summarizers.
author cmlenz
date Tue, 07 Aug 2007 09:17:30 +0000
parents 933105ab516b
children
rev   line source
379
0df178e07fdb Use UTF-8 as encoding of source files.
cmlenz
parents: 376
diff changeset
1 # -*- coding: utf-8 -*-
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
2 #
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
3 # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de>
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
4 # Copyright (C) 2007 Edgewall Software
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
5 # 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
6 #
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
7 # This software is licensed as described in the file COPYING, which
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 161
diff changeset
8 # you should have received as part of this distribution. The terms
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 391
diff changeset
9 # are also available at http://bitten.edgewall.org/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
10
316
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
11 """Implementation of the Bitten web interface."""
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
12
295
5f84af72d17f * Store executable bit in ZIP archives (from `svn:executable`).
cmlenz
parents: 263
diff changeset
13 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
14 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
15 import re
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
16 try:
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
17 set
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
18 except NameError:
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
19 from sets import Set as set
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
20 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
21
99
efc1eed69ba8 Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents: 98
diff changeset
22 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
23 from trac.core import *
362
4645863d7966 Fix for a compatibility problem with Trac 0.11dev.
cmlenz
parents: 361
diff changeset
24 try:
4645863d7966 Fix for a compatibility problem with Trac 0.11dev.
cmlenz
parents: 361
diff changeset
25 from trac.timeline import ITimelineEventProvider
4645863d7966 Fix for a compatibility problem with Trac 0.11dev.
cmlenz
parents: 361
diff changeset
26 except ImportError:
4645863d7966 Fix for a compatibility problem with Trac 0.11dev.
cmlenz
parents: 361
diff changeset
27 from trac.Timeline import ITimelineEventProvider
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
28 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line, \
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
29 Markup
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
30 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
31 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
32 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
33 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
34 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
35 BuildLog, Report
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
36 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
37 from bitten.recipe import Recipe, InvalidRecipeError
409
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
38 from bitten.trac_ext.api import ILogFormatter, IReportChartGenerator, \
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
39 IReportSummarizer
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
40 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
41
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
42 _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
43 Build.IN_PROGRESS: 'in progress',
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
44 Build.SUCCESS: 'completed',
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
45 Build.FAILURE: 'failed'}
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
46
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
47 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
48 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
49 'status': _status_label[build.status],
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
50 'cls': _status_label[build.status].replace(' ', '-'),
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
51 'href': req.href.build(build.config, build.id),
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
52 'chgset_href': req.href.changeset(build.rev)}
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
53 if build.started:
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
54 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
55 hdf['started_delta'] = pretty_timedelta(build.started)
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
56 hdf['duration'] = pretty_timedelta(build.started)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
57 if build.stopped:
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
58 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
59 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
60 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
61 hdf['slave'] = {
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
62 'name': build.slave,
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
63 'ipnr': build.slave_info.get(Build.IP_ADDRESS),
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
64 '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
65 '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
66 '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
67 '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
68 '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
69 }
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
70 return hdf
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
71
318
c042e2c7048c Minor cleanup.
cmlenz
parents: 316
diff changeset
72
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
73 class BittenChrome(Component):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
74 """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
75
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
76 implements(INavigationContributor, ITemplateProvider)
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
77
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
78 # 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
79
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
80 def get_active_navigation_item(self, req):
316
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
81 """Called by Trac to determine which navigation item should be marked
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
82 as active.
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
83
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
84 @param req: the request object
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
85 """
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
86 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
87
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
88 def get_navigation_items(self, req):
316
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
89 """Return the navigation item for access the build status overview from
87c9b1e8f086 More docstring improvements.
cmlenz
parents: 311
diff changeset
90 the Trac navigation bar."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
91 if not req.perm.has_permission('BUILD_VIEW'):
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
92 return
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
93 yield ('mainnav', 'build', \
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
94 Markup('<a href="%s" accesskey="5">Build Status</a>',
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
95 req.href.build()))
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
96
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
97 # ITemplatesProvider methods
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
98
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
99 def get_htdocs_dirs(self):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
100 """Return the directories containing static resources."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
101 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))]
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
102
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
103 def get_templates_dirs(self):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
104 """Return the directories containing templates."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
105 return [pkg_resources.resource_filename(__name__, 'templates')]
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
106
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
107
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
108 class BuildConfigController(Component):
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
109 """Implements the web interface for build configurations."""
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
110
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
111 implements(IRequestHandler)
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
112
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
113 # 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
114
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
115 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
116 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
117 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
118 if match.group(1):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
119 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
120 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
121
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
122 def process_request(self, req):
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
123 req.perm.assert_permission('BUILD_VIEW')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
124
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
125 action = req.args.get('action')
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
126 view = req.args.get('view')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
127 config = req.args.get('config')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
128
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
129 if req.method == 'POST':
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
130 if config:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
131 if action == 'new':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
132 self._do_create_platform(req, config)
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
133 elif action == 'delete':
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
134 self._do_delete_config(req, config)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
135 else:
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:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
138 if action == 'edit':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
139 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
140 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
141 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
142 self._render_config_form(req, config)
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
143 elif 'new' in req.args:
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
144 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
145 self._render_platform_form(req, platform)
73
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._do_save_config(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
148 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
149 if action == 'new':
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
150 self._do_create_config(req)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
151 else:
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
152 if config:
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
153 if action == 'delete':
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
154 self._render_config_confirm(req, config)
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
155 elif action == 'edit':
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
156 platform_id = req.args.get('platform')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
157 if platform_id:
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
158 platform = TargetPlatform.fetch(self.env,
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
159 int(platform_id))
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
160 self._render_platform_form(req, platform)
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
161 elif 'new' in req.args:
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
162 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
163 self._render_platform_form(req, platform)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
164 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
165 self._render_config_form(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
166 else:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
167 self._render_config(req, config)
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
168 else:
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
169 if action == 'new':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
170 self._render_config_form(req)
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
171 elif view == 'inprogress':
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
172 self._render_inprogress(req)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
173 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
174 self._render_overview(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
175
164
a9cddfae3c09 Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents: 163
diff changeset
176 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
177 return 'bitten_config.cs', None
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
178
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
179 # Internal methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
180
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
181 def _do_create_config(self, req):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
182 """Create a new build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
183 req.perm.assert_permission('BUILD_CREATE')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
184
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
185 if 'cancel' in req.args:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
186 req.redirect(req.href.build())
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
187
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
188 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
189
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
190 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
191 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
192 '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
193
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
194 config = BuildConfig(self.env)
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
195 self._process_config(req, config)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
196 config.insert()
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
197
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
198 req.redirect(req.href.build(config.name))
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
199
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
200 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
201 """Save changes to a build configuration."""
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
202 req.perm.assert_permission('BUILD_DELETE')
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
203
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
204 if 'cancel' in req.args:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
205 req.redirect(req.href.build(config_name))
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
206
200
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
207 db = self.env.get_db_cnx()
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
208
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
209 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
210 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
211
200
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
212 config.delete(db=db)
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
213
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
214 db.commit()
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
215
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
216 req.redirect(req.href.build())
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
217
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
218 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
219 """Save changes to a build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
220 req.perm.assert_permission('BUILD_MODIFY')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
221
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
222 if 'cancel' in req.args:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
223 req.redirect(req.href.build(config_name))
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
224
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
225 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
226 if not config:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
227 # FIXME: 404
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
228 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
229 % 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
230
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
231 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
232 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
233
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
234 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
235 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
236
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
237 else:
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
238 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
239
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
240 config.update()
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
241 req.redirect(req.href.build(config.name))
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
242
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
243 def _process_config(self, req, config):
328
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
244 name = req.args.get('name')
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
245 if not name:
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
246 raise TracError('Missing required field "name"', 'Missing field')
328
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
247 if not re.match(r'^[\w.-]+$', name):
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
248 raise TracError('The field "name" may only contain letters, '
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
249 'digits, periods, or dashes.', 'Invalid field')
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
250
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
251 path = req.args.get('path', '')
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
252 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
253 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
254 try:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
255 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
256 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
257 except (AssertionError, TracError), e:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
258 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
259 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
260 try:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
261 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
262 except TracError, e:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
263 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
264
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
265 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
266 if recipe_xml:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
267 try:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
268 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
269 except xmlio.ParseError, e:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
270 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
271 'Invalid recipe')
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
272 except InvalidRecipeError, e:
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
273 raise TracError(e, 'Invalid recipe')
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
274
328
76a3f40d163e Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
cmlenz
parents: 321
diff changeset
275 config.name = name
247
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
276 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
277 config.recipe = recipe_xml
b28285d3ceec Add validation for build configurations, and in particular for build recipes. Closes #48.
cmlenz
parents: 245
diff changeset
278 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
279 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
280 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
281 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
282
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
283 def _do_create_platform(self, req, config_name):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
284 """Create a new target platform."""
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
285 req.perm.assert_permission('BUILD_MODIFY')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
286
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
287 if 'cancel' in req.args:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
288 req.redirect(req.href.build(config_name, action='edit'))
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
289
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
290 platform = TargetPlatform(self.env, config=config_name)
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
291 if self._process_platform(req, platform):
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
292 platform.insert()
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
293 req.redirect(req.href.build(config_name, action='edit'))
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
294
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
295 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
296 """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
297 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
298 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
299
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
300 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
301 for platform_id in [int(id) for id in req.args.get('delete_platform')]:
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
302 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
303 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
304 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
305 platform.delete(db=db)
200
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
306
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
307 # 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
308 # platform, and all the associated reports
692924ffed80 Changes to the BDB XML report store to support transactions. Closes #47.
cmlenz
parents: 198
diff changeset
309
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
310 db.commit()
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
311
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
312 def _do_save_platform(self, req, config_name, platform_id):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
313 """Save changes to a target platform."""
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
314 req.perm.assert_permission('BUILD_MODIFY')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
315
98
1d9dc07acd3d Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents: 96
diff changeset
316 if 'cancel' in req.args:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
317 req.redirect(req.href.build(config_name, action='edit'))
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
318
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
319 platform = TargetPlatform.fetch(self.env, platform_id)
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
320 if self._process_platform(req, platform):
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
321 platform.update()
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
322 req.redirect(req.href.build(config_name, action='edit'))
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
323
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
324 def _process_platform(self, req, platform):
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
325 platform.name = req.args.get('name')
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
326
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
327 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
328 if key.startswith('property_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
329 properties.sort()
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
330 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
331 if key.startswith('pattern_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
332 patterns.sort()
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
333 platform.rules = [(req.args.get('property_%d' % property),
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
334 req.args.get('pattern_%d' % pattern))
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
335 for property, pattern in zip(properties, patterns)
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
336 if req.args.get('property_%d' % property)]
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
337
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
338 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
339 if key.startswith('add_rule_')]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
340 if add_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
341 platform.rules.insert(add_rules[0] + 1, ('', ''))
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
342 self._render_platform_form(req, platform)
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
343 return False
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
344 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
345 if key.startswith('rm_rule_')]
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
346 if rm_rules:
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
347 del platform.rules[rm_rules[0]]
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
348 self._render_platform_form(req, platform)
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
349 return False
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
350
192
da2a2e9a8f71 Fix target platform management under mod_python. Closes #44.
cmlenz
parents: 184
diff changeset
351 return True
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
352
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
353 def _render_overview(self, req):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
354 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
355 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
356 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
357 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
358 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
359
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
360 add_link(req, 'views', req.href.build(view='inprogress'), 'In Progress Builds')
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
361
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
362 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
363 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
364 prefix = 'configs.%d' % idx
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
365 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
366 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
367 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
368 req.hdf[prefix] = {
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
369 '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
370 '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
371 'description': description,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
372 'href': req.href.build(config.name),
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
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 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
375 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
376
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
377 repos = self.env.get_repository(req.authname)
360
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
378 if hasattr(repos, 'sync'):
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
379 repos.sync()
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
380
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
381 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
382 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
383 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
384 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
385 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
386 req.hdf[prefix + '.youngest_rev'] = {
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
387 'id': rev, 'href': req.href.changeset(rev),
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
388 'author': 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
389 '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
390 '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
391 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
392 }
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
393 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
394 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
395 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
396 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
397 build_hdf = _build_to_hdf(self.env, req, build)
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
398 build_hdf['platform'] = platform.name
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
399 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
400 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
401 req.hdf[prefix + '.builds.%d' % platform.id] = {
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
402 'platform': platform.name, 'status': 'pending'
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
403 }
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
404
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
405 req.hdf['page.mode'] = 'overview'
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
406 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
407
381
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
408 def _render_inprogress(self, req):
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
409 req.hdf['title'] = 'In Progress Builds'
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
410
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
411 db = self.env.get_db_cnx()
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
412
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
413 configs = BuildConfig.select(self.env, include_inactive=False)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
414 for idx, config in enumerate(configs):
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
415 if not config.active:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
416 continue
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
417
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
418 in_progress_builds = Build.select(self.env, config=config.name,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
419 status=Build.IN_PROGRESS, db=db)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
420
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
421 # sort correctly by revision.
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
422 builds = list(in_progress_builds)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
423 builds.sort(lambda x, y: int(y.rev) - int(x.rev))
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
424 prefix = 'configs.%d' % idx
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
425
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
426 current_builds = 0
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
427 for idx2, build in enumerate(builds):
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
428 prefix2 = '%s.builds.%d' % (prefix, idx2)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
429 rev = build.rev
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
430 req.hdf[prefix2] = _build_to_hdf(self.env, req, build)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
431 req.hdf[prefix2 + '.rev'] = rev
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
432 req.hdf[prefix2 + '.rev_href'] = self.env.href.changeset(rev)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
433 platform = TargetPlatform.fetch(self.env, build.platform)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
434 req.hdf[prefix2 + '.platform'] = platform.name
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
435
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
436 for step in BuildStep.select(self.env, build=build.id, db=db):
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
437 req.hdf['%s.steps.%s' % (prefix2, step.name)] = {
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
438 'description': step.description,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
439 'duration': datetime.fromtimestamp(step.stopped) - \
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
440 datetime.fromtimestamp(step.started),
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
441 'failed': not step.successful,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
442 'errors': step.errors,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
443 'href': req.hdf[prefix2 + '.href'] + '#step_' + step.name }
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
444
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
445 current_builds = current_builds + 1
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
446
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
447 if current_builds == 0:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
448 continue
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
449
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
450 description = config.description
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
451 if description:
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
452 description = wiki_to_html(description, self.env, req)
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
453 req.hdf[prefix] = {
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
454 'name': config.name, 'label': config.label or config.name,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
455 'active': config.active, 'path': config.path,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
456 'description': description,
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
457 'href': self.env.href.build(config.name),
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
458 }
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
459
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
460 req.hdf['page.mode'] = 'view_inprogress'
166dcdb9269e New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents: 379
diff changeset
461
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
462 def _render_config(self, req, config_name):
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
463 db = self.env.get_db_cnx()
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
464
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
465 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
466 req.hdf['title'] = 'Build Configuration "%s"' \
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
467 % config.label or config.name
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
468 add_link(req, 'up', req.href.build(), 'Build Status')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
469 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
470 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
471 description = wiki_to_html(description, self.env, req)
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
472 req.hdf['config'] = {
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
473 'name': config.name, 'label': config.label, 'path': config.path,
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
474 'min_rev': config.min_rev,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
475 'min_rev_href': req.href.changeset(config.min_rev),
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
476 'max_rev': config.max_rev,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
477 'max_rev_href': req.href.changeset(config.max_rev),
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
478 'active': config.active, 'description': description,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
479 'browser_href': req.href.browser(config.path),
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
480 '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
481 '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
482 }
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
483 req.hdf['page.mode'] = 'view_config'
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
484
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
485 platforms = list(TargetPlatform.select(self.env, config=config_name,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
486 db=db))
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
487 req.hdf['config.platforms'] = [
76
ffa1ffd8c7db * Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents: 74
diff changeset
488 {'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
489 ]
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
490
197
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
491 has_reports = False
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
492 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
493 has_reports = True
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
494 break
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
495
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
496 if has_reports:
388
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
497 chart_generators = []
391
7801dddec1a1 Sign, another follow-up to [438]. One of these days I should get it right :-(
cmlenz
parents: 390
diff changeset
498 for generator in ReportChartController(self.env).generators:
388
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
499 for category in generator.get_supported_categories():
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
500 chart_generators.append({
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
501 'href': req.href.build(config.name, 'chart/' + category)
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
502 })
3ba9430a5d87 Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents: 382
diff changeset
503 req.hdf['config.charts'] = chart_generators
197
d72c0587fae9 * Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents: 196
diff changeset
504 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
505 if charts_license:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
506 req.hdf['config.charts_license'] = 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
507
214
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
508 page = max(1, int(req.args.get('page', 1)))
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
509 more = False
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
510 req.hdf['page.number'] = page
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
511
360
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
512 repos = self.env.get_repository(req.authname)
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
513 if hasattr(repos, 'sync'):
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
514 repos.sync()
5bc81e597352 Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents: 328
diff changeset
515
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
516 builds_per_page = 12 * len(platforms)
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
517 idx = 0
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
518 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
519 if idx >= page * builds_per_page:
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
520 more = True
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
521 break
232
b6e4896dc026 Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents: 230
diff changeset
522 elif idx >= (page - 1) * builds_per_page:
230
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
523 prefix = 'config.builds.%d' % rev
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
524 req.hdf[prefix + '.href'] = req.href.changeset(rev)
230
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
525 if build and build.status != Build.PENDING:
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
526 build_hdf = _build_to_hdf(self.env, req, build)
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
527 req.hdf['%s.%s' % (prefix, platform.id)] = build_hdf
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
528 for step in BuildStep.select(self.env, build=build.id,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
529 db=db):
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
530 req.hdf['%s.%s.steps.%s' % (prefix, platform.id,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
531 step.name)] = {
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
532 'description': step.description,
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
533 'duration': datetime.fromtimestamp(step.stopped) - \
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
534 datetime.fromtimestamp(step.started),
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
535 'failed': not step.successful,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
536 'errors': step.errors,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
537 'href': build_hdf['href'] + '#step_' + step.name,
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
538 }
230
c7ff953ebb07 Fix paging on build configuration page. Closes #55.
cmlenz
parents: 228
diff changeset
539 idx += 1
214
f0e37bee64c5 Paging on build configuration page. Closes #24.
cmlenz
parents: 213
diff changeset
540
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
541 if page > 1:
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
542 if page == 2:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
543 prev_href = req.href.build(config.name)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
544 else:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
545 prev_href = req.href.build(config.name, page=page - 1)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
546 add_link(req, 'prev', prev_href, 'Previous Page')
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
547 if more:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
548 next_href = req.href.build(config.name, page=page + 1)
228
a8c9dd7e3f71 * Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents: 219
diff changeset
549 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
550
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
551 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
552 req.perm.assert_permission('BUILD_DELETE')
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
553 config = BuildConfig.fetch(self.env, config_name)
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
554 req.hdf['title'] = 'Delete Build Configuration "%s"' \
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
555 % config.label or config.name
195
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
556 req.hdf['config'] = {'name': config.name}
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
557 req.hdf['page.mode'] = 'delete_config'
bd6234ed6ac5 Allow deletion of build configurations from the web interface. Closes #27.
cmlenz
parents: 192
diff changeset
558
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
559 def _render_config_form(self, req, config_name=None):
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
560 config = BuildConfig.fetch(self.env, config_name)
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
561 if config:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
562 req.perm.assert_permission('BUILD_MODIFY')
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
563 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
564 '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
565 '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
566 '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
567 '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
568 'description': config.description
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
569 }
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
570
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
571 req.hdf['title'] = 'Edit Build Configuration "%s"' \
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
572 % config.label or config.name
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
573 for idx, platform in enumerate(TargetPlatform.select(self.env,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
574 config_name)):
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
575 req.hdf['config.platforms.%d' % idx] = {
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
576 'id': platform.id, 'name': platform.name,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
577 'href': req.href.build(config_name, action='edit',
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
578 platform=platform.id)
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
579 }
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
580 else:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
581 req.perm.assert_permission('BUILD_CREATE')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
582 req.hdf['title'] = 'Create Build Configuration'
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
583 req.hdf['page.mode'] = 'edit_config'
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
584
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
585 def _render_platform_form(self, req, platform):
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
586 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
587 if platform.exists:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
588 req.hdf['title'] = 'Edit Target Platform "%s"' % platform.name
74
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
589 else:
1d4fa4c32afa Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents: 73
diff changeset
590 req.hdf['title'] = 'Add Target Platform'
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
591 req.hdf['platform'] = {
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
592 'name': platform.name, 'id': platform.id, 'exists': platform.exists,
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
593 '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
594 for propname, pattern in platform.rules] or [('', '')]
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
595 }
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
596 req.hdf['page.mode'] = 'edit_platform'
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
597
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
598
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
599 class BuildController(Component):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
600 """Renders the build page."""
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
601 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
602
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
603 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
604 report_summarizers = ExtensionPoint(IReportSummarizer)
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
605
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
606 # INavigationContributor methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
607
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
608 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
609 return 'build'
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
610
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
611 def get_navigation_items(self, req):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
612 return []
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
613
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
614 # IRequestHandler methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
615
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
616 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
617 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
618 if match:
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
619 if match.group(1):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
620 req.args['config'] = match.group(1)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
621 if match.group(2):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
622 req.args['id'] = match.group(2)
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
623 return True
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
624
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
625 def process_request(self, req):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
626 req.perm.assert_permission('BUILD_VIEW')
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
627
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
628 db = self.env.get_db_cnx()
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
629 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
630 build = Build.fetch(self.env, build_id, db=db)
96
c8c36f34ff5a Change model class pattern:
cmlenz
parents: 91
diff changeset
631 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
632
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
633 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
634 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
635 self._do_invalidate(req, build, db)
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
636 req.redirect(req.href.build(build.config, build.id))
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
637
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
638 add_link(req, 'up', req.href.build(build.config),
73
6d7753ea1798 Implemented basic management of target platforms. Closes #14.
cmlenz
parents: 69
diff changeset
639 'Build Configuration')
91
91db738c6a74 Fix status display for in-progress builds.
cmlenz
parents: 82
diff changeset
640 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure',
91db738c6a74 Fix status display for in-progress builds.
cmlenz
parents: 82
diff changeset
641 Build.IN_PROGRESS: 'In Progress'}
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
642 req.hdf['title'] = 'Build %s - %s' % (build_id,
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
643 status2title[build.status])
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
644 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
645 config = BuildConfig.fetch(self.env, build.config, db=db)
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
646 req.hdf['build.config'] = {
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
647 'name': config.label,
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
648 'href': req.href.build(config.name)
69
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
649 }
b92d7c7d70fd Record build slave properties in database.
cmlenz
parents: 67
diff changeset
650
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
651 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
652 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
653 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
654
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
655 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
656 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
657 categories = summarizer.get_supported_categories()
361
109800464463 `dict.update` can take a sequence of key/value pairs, so remove redundant building of another dict
mgood
parents: 360
diff changeset
658 summarizers.update([(cat, summarizer) for cat in categories])
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
659
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
660 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
661 steps = []
112
a38eabd4b6e1 * Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents: 111
diff changeset
662 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
663 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
664 'name': step.name, 'description': step.description,
123
cccfa117e344 Template cleanup
cmlenz
parents: 120
diff changeset
665 '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
666 'failed': step.status == BuildStep.FAILURE,
245
a22ec8fce6c9 Store the reason(s) for build step failure in the database.
cmlenz
parents: 232
diff changeset
667 '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
668 '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
669 '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
670 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
671 })
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
672 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
673 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
674
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
675 repos = self.env.get_repository(req.authname)
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
676 chgset = repos.get_changeset(build.rev)
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
677 req.hdf['build.chgset_author'] = chgset.author
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
678
164
a9cddfae3c09 Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents: 163
diff changeset
679 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
680 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
681
141
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
682 # ITimelineEventProvider methods
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
683
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
684 def get_timeline_filters(self, req):
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
685 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
686 yield ('build', 'Builds')
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
687
0e21778c04ef Refactoring: split up the components and templates that render the web interface.
cmlenz
parents: 139
diff changeset
688 def get_timeline_events(self, req, start, stop, filters):
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
689 if 'build' not in filters:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
690 return
250
0271a2b1fc23 Improvements to the web interface:
cmlenz
parents: 247
diff changeset
691
382
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
692 if isinstance(start, datetime): # Trac>=0.11
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
693 from trac.util.datefmt import to_timestamp
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
694 start = to_timestamp(start)
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
695 stop = to_timestamp(stop)
2078b20186cf Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents: 381
diff changeset
696
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
697 add_stylesheet(req, 'bitten/bitten.css')
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
698
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
699 db = self.env.get_db_cnx()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
700 cursor = db.cursor()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
701 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name,"
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
702 "b.stopped,b.status FROM bitten_build AS b"
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
703 " INNER JOIN bitten_config AS c ON (c.name=b.config) "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
704 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
705 "WHERE b.stopped>=%s AND b.stopped<=%s "
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
706 "AND b.status IN (%s, %s) ORDER BY b.stopped",
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
707 (start, stop, Build.SUCCESS, Build.FAILURE))
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
708
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
709 event_kinds = {Build.SUCCESS: 'successbuild',
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
710 Build.FAILURE: 'failedbuild'}
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
711 for id, config, label, rev, platform, stopped, status in cursor:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
712
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
713 errors = []
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
714 if status == Build.FAILURE:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
715 for step in BuildStep.select(self.env, build=id,
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
716 status=BuildStep.FAILURE,
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
717 db=db):
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
718 errors += [(step.name, error) for error
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
719 in step.errors]
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
720
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
721 title = Markup('Build of <em>%s [%s]</em> on %s %s', label, rev,
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
722 platform, _status_label[status])
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
723 message = ''
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
724 if req.args.get('format') == 'rss':
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
725 href = self.env.abs_href.build(config, id)
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
726 if errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
727 buf = StringIO()
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
728 prev_step = None
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
729 for step, error in errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
730 if step != prev_step:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
731 if prev_step is not None:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
732 buf.write('</ul>')
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
733 buf.write('<p>Step %s failed:</p><ul>' \
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
734 % escape(step))
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
735 prev_step = step
321
8e8d40d50001 Removed too much of the escaping in [333].
cmlenz
parents: 320
diff changeset
736 buf.write('<li>%s</li>' % escape(error))
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
737 buf.write('</ul>')
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
738 message = Markup(buf.getvalue())
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
739 else:
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
740 href = req.href.build(config, id)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
741 if errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
742 steps = []
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
743 for step, error in errors:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
744 if step not in steps:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
745 steps.append(step)
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
746 steps = [Markup('<em>%s</em>', step) for step in steps]
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
747 if len(steps) < 2:
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
748 message = steps[0]
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
749 elif len(steps) == 2:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
750 message = Markup(' and ').join(steps)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
751 elif len(steps) > 2:
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
752 message = Markup(', ').join(steps[:-1]) + ', and ' + \
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
753 steps[-1]
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
754 message = Markup('Step%s %s failed',
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
755 len(steps) != 1 and 's' or '', message)
311
7f6fc38e14ff More assertions in `Build` model methods.
cmlenz
parents: 295
diff changeset
756 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
757
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
758 # 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
759
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
760 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
761 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
762
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
763 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
764 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
765
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
766 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
767 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
768 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
769 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
770 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
771
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
772 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
773
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
774 req.redirect(req.href.build(build.config))
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
775
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
776 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
777 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
778 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
779 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
780 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
781 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
782 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
783 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
784
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
785 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
786 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
787 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
788 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
789 if summarizer:
213
25f84dd9f159 * Refactoring of build recipes, the file format has changed slightly:
cmlenz
parents: 209
diff changeset
790 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
791 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
792 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
793 summary = None
320
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
794 reports.append({'category': report.category,
a8b713254286 Fixes for compatibility with Trac trunk and 0.9.3.
cmlenz
parents: 318
diff changeset
795 'summary': Markup(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
796 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
797
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
798
409
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
799 class ReportChartController(Component):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
800 implements(IRequestHandler)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
801
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
802 generators = ExtensionPoint(IReportChartGenerator)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
803
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
804 # IRequestHandler methods
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
805
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
806 def match_request(self, req):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
807 match = re.match(r'/build/([\w.-]+)/chart/(\w+)', req.path_info)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
808 if match:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
809 req.args['config'] = match.group(1)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
810 req.args['category'] = match.group(2)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
811 return True
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
812
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
813 def process_request(self, req):
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
814 category = req.args.get('category')
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
815 config = BuildConfig.fetch(self.env, name=req.args.get('config'))
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
816
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
817 for generator in self.generators:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
818 if category in generator.get_supported_categories():
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
819 template = generator.generate_chart_data(req, config,
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
820 category)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
821 break
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
822 else:
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
823 raise TracError('Unknown report category "%s"' % category)
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
824
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
825 return template, 'text/xml'
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
826
5786700df0c7 Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents: 408
diff changeset
827
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
828 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
829 """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
830 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
831
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
832 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
833
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
834 _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
835
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
836 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
837 """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
838 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
839 repos = self.env.get_repository(req.authname)
376
05c684ceb8c6 Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents: 362
diff changeset
840 href = req.href.browser
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
841 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
842 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
843 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
844 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
845 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
846 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
847 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
848 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
849 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
850 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
851 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
852 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
853 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
854 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
855 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
856 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
857 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
858 return '<a href="%s">%s</a>' % (
263
688501d1d342 * Fix links in build log formatter.
cmlenz
parents: 262
diff changeset
859 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
860 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
861 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
862 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
863 return _formatter
Copyright (C) 2012-2017 Edgewall Software