Mercurial > bitten > bitten-test
annotate bitten/web_ui.py @ 504:e2eef154f1af
Add pending/inprogress build counts to web ui.
author | wbell |
---|---|
date | Mon, 09 Mar 2009 01:07:15 +0000 |
parents | a7c795920c4a |
children | be811cb659b7 |
rev | line source |
---|---|
379 | 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 | 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 | 7 # This software is licensed as described in the file COPYING, which |
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 | 11 """Implementation of the Bitten web interface.""" |
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 | 16 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
|
17 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
18 import pkg_resources |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
19 from genshi.builder import tag |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
20 from trac.core import * |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
21 from trac.timeline import ITimelineEventProvider |
321 | 22 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line, \ |
23 Markup | |
439 | 24 from trac.util.html import html |
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
|
25 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
|
26 from trac.web.chrome import INavigationContributor, ITemplateProvider, \ |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
27 add_link, add_stylesheet, add_ctxtnav, \ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
28 prevnext_nav, add_script |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
29 from trac.wiki import wiki_to_html, wiki_to_oneliner |
410
7930cdd83d13
More restructuring: got rid of the `trac_ext` subpackage, which makes no sense now that the master is also coupled to Trac.
cmlenz
parents:
409
diff
changeset
|
30 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer |
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
|
31 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
|
32 BuildLog, Report |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
33 from bitten.queue import collect_changes |
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
|
34 |
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
|
35 _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
|
36 Build.IN_PROGRESS: 'in progress', |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
37 Build.SUCCESS: 'completed', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
38 Build.FAILURE: 'failed'} |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
39 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
40 def _get_build_data(env, req, build): |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
41 data = {'id': build.id, 'name': build.slave, 'rev': build.rev, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
42 'status': _status_label[build.status], |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
43 'cls': _status_label[build.status].replace(' ', '-'), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
44 'href': req.href.build(build.config, build.id), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
45 '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
|
46 if build.started: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
47 data['started'] = format_datetime(build.started) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
48 data['started_delta'] = pretty_timedelta(build.started) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
49 data['duration'] = pretty_timedelta(build.started) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
50 if build.stopped: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
51 data['stopped'] = format_datetime(build.stopped) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
52 data['stopped_delta'] = pretty_timedelta(build.stopped) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
53 data['duration'] = pretty_timedelta(build.stopped, build.started) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
54 data['slave'] = { |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
55 'name': build.slave, |
250 | 56 'ipnr': build.slave_info.get(Build.IP_ADDRESS), |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
57 'os_name': build.slave_info.get(Build.OS_NAME), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
58 'os_family': build.slave_info.get(Build.OS_FAMILY), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
59 'os_version': build.slave_info.get(Build.OS_VERSION), |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
60 '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
|
61 '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
|
62 } |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
63 return data |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
64 |
318 | 65 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
66 class BittenChrome(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
67 """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
|
68 |
320 | 69 implements(INavigationContributor, ITemplateProvider) |
64 | 70 |
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
|
71 # 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
|
72 |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
73 def get_active_navigation_item(self, req): |
316 | 74 """Called by Trac to determine which navigation item should be marked |
75 as active. | |
76 | |
411
a169d2e96463
Use reStructuredText as the API documentation syntax.
cmlenz
parents:
410
diff
changeset
|
77 :param req: the request object |
316 | 78 """ |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
79 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
|
80 |
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
|
81 def get_navigation_items(self, req): |
316 | 82 """Return the navigation item for access the build status overview from |
83 the Trac navigation bar.""" | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
84 if 'BUILD_VIEW' in req.perm: |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
85 yield ('mainnav', 'build', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
86 tag.a('Builds Status', href=req.href.build(), accesskey=5)) |
320 | 87 |
88 # ITemplatesProvider methods | |
89 | |
90 def get_htdocs_dirs(self): | |
91 """Return the directories containing static resources.""" | |
92 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))] | |
93 | |
94 def get_templates_dirs(self): | |
95 """Return the directories containing templates.""" | |
96 return [pkg_resources.resource_filename(__name__, 'templates')] | |
97 | |
98 | |
99 class BuildConfigController(Component): | |
100 """Implements the web interface for build configurations.""" | |
101 | |
102 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
|
103 |
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
|
104 # 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
|
105 |
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
|
106 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
|
107 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
|
108 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
|
109 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
110 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
|
111 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
|
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 def process_request(self, req): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
114 req.perm.require('BUILD_VIEW') |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
115 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
116 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
|
117 view = req.args.get('view') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
118 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
119 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
120 if config: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
121 data = self._render_config(req, config) |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
122 elif view == 'inprogress': |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
123 data = self._render_inprogress(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
124 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
125 data = self._render_overview(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
126 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
127 add_stylesheet(req, 'bitten/bitten.css') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
128 return 'bitten_config.html', data, None |
64 | 129 |
130 # Internal methods | |
131 | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
132 def _render_overview(self, req): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
133 data = {'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
|
134 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
|
135 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
|
136 show_all = True |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
137 data['show_all'] = show_all |
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
|
138 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
139 configs = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
140 for config in BuildConfig.select(self.env, include_inactive=show_all): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
141 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
142 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
143 description = wiki_to_html(description, self.env, req) |
504 | 144 |
145 platforms_data = [] | |
146 for platform in TargetPlatform.select(self.env, config=config.name): | |
147 pd = { 'name': platform.name, | |
148 'id': platform.id, | |
149 'builds_pending': len(list(Build.select(self.env, config=config.name, status=Build.PENDING, platform=platform.id))), | |
150 'builds_inprogress': len(list(Build.select(self.env, config=config.name, status=Build.IN_PROGRESS, platform=platform.id))) | |
151 } | |
152 platforms_data.append(pd) | |
153 | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
154 config_data = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
155 '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
|
156 '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
|
157 'description': description, |
504 | 158 'builds_pending' : len(list(Build.select(self.env, config=config.name, status=Build.PENDING))), |
159 'builds_inprogress' : len(list(Build.select(self.env, config=config.name, status=Build.IN_PROGRESS))), | |
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
|
160 'href': req.href.build(config.name), |
504 | 161 'builds': [], |
162 'platforms': platforms_data | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
163 } |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
164 configs.append(config_data) |
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
|
165 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
|
166 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
|
167 |
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
|
168 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
|
169 if hasattr(repos, 'sync'): |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
170 repos.sync() |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
171 |
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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 chgset = repos.get_changeset(rev) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
177 config_data['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
|
178 'id': rev, 'href': req.href.changeset(rev), |
320 | 179 '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
|
180 '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
|
181 'message': wiki_to_oneliner( |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
182 shorten_line(chgset.message), self.env, req=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
|
183 } |
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
|
184 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
|
185 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
|
186 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
|
187 if build: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
188 build_data = _get_build_data(self.env, req, build) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
189 build_data['platform'] = platform.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
190 config_data['builds'].append(build_data) |
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
|
191 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
192 config_data['builds'].append({ |
320 | 193 'platform': platform.name, 'status': 'pending' |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
194 }) |
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
|
195 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
196 data['configs'] = configs |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
197 data['page_mode'] = 'overview' |
504 | 198 |
199 in_progress_builds = Build.select(self.env, status=Build.IN_PROGRESS) | |
200 pending_builds = Build.select(self.env, status=Build.PENDING) | |
201 | |
202 data['builds_pending'] = len(list(pending_builds)) | |
203 data['builds_inprogress'] = len(list(in_progress_builds)) | |
204 | |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
205 add_link(req, 'views', req.href.build(view='inprogress'), |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
206 'In Progress Builds') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
207 add_ctxtnav(req, 'In Progress Builds', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
208 req.href.build(view='inprogress')) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
209 return data |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
210 |
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
|
211 def _render_inprogress(self, req): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
212 data = {'title': 'In Progress Builds', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
213 'page_mode': 'view-inprogress'} |
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
|
214 |
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
|
215 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
|
216 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
217 configs = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
218 for config in BuildConfig.select(self.env, include_inactive=False): |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
219 self.log.debug(config.name) |
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
|
220 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
|
221 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
|
222 |
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
|
223 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
|
224 status=Build.IN_PROGRESS, db=db) |
437
6d5ac24061dc
Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents:
436
diff
changeset
|
225 |
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
|
226 current_builds = 0 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
227 builds = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
228 # sort correctly by revision. |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
229 for build in sorted(in_progress_builds, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
230 cmp=lambda x, y: int(y.rev) - int(x.rev)): |
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
|
231 rev = build.rev |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
232 build_data = _get_build_data(self.env, req, build) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
233 build_data['rev'] = rev |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
234 build_data['rev_href'] = req.href.changeset(rev) |
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
|
235 platform = TargetPlatform.fetch(self.env, build.platform) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
236 build_data['platform'] = platform.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
237 build_data['steps'] = [] |
437
6d5ac24061dc
Fix build queue population compatiblity with Trac 0.11, where revision timestamps are `datetime` objects.
cmlenz
parents:
436
diff
changeset
|
238 |
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
|
239 for step in BuildStep.select(self.env, build=build.id, db=db): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
240 build_data['steps'].append({ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
241 'name': step.name, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
242 'description': step.description, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
243 'duration': datetime.fromtimestamp(step.stopped) - \ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
244 datetime.fromtimestamp(step.started), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
245 'failed': not step.successful, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
246 'errors': step.errors, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
247 'href': build_data['href'] + '#step_' + step.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
248 }) |
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
|
249 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
250 builds.append(build_data) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
251 current_builds += 1 |
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
|
252 |
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
|
253 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
|
254 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
|
255 |
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
|
256 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
|
257 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
|
258 description = wiki_to_html(description, self.env, req) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
259 configs.append({ |
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
|
260 '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
|
261 '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
|
262 'description': description, |
460
32b61f031df0
Fix a couple of left-over instances of using `env.href` instead of `req.href`. Closes #186. Thanks to Markus Heberling for reporting the issue and providing a patch.
cmlenz
parents:
440
diff
changeset
|
263 'href': req.href.build(config.name), |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
264 'builds': builds |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
265 }) |
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
|
266 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
267 data['configs'] = configs |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
268 return data |
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
|
269 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
270 def _render_config(self, req, config_name): |
250 | 271 db = self.env.get_db_cnx() |
272 | |
273 config = BuildConfig.fetch(self.env, config_name, db=db) | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
274 data = {'title': 'Build Configuration "%s"' \ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
275 % config.label or config.name, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
276 'page_mode': 'view_config'} |
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
|
277 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
|
278 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
279 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
280 description = wiki_to_html(description, self.env, req) |
504 | 281 |
282 pending_builds = list(Build.select(self.env, config=config.name, status=Build.PENDING)) | |
283 inprogress_builds = list(Build.select(self.env, config=config.name, status=Build.IN_PROGRESS)) | |
284 | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
285 data['config'] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
286 'name': config.name, 'label': config.label, 'path': config.path, |
250 | 287 '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
|
288 'min_rev_href': req.href.changeset(config.min_rev), |
250 | 289 '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
|
290 '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
|
291 'active': config.active, 'description': description, |
504 | 292 'browser_href': req.href.browser(config.path), |
293 'builds_pending' : len(pending_builds), | |
294 'builds_inprogress' : len(inprogress_builds) | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
295 } |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
296 |
250 | 297 platforms = list(TargetPlatform.select(self.env, config=config_name, |
298 db=db)) | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
299 data['config']['platforms'] = [ |
504 | 300 { 'name': platform.name, |
301 'id': platform.id, | |
302 'builds_pending': len(list(Build.select(self.env, config=config.name, status=Build.PENDING, platform=platform.id))), | |
303 'builds_inprogress': len(list(Build.select(self.env, config=config.name, status=Build.IN_PROGRESS, platform=platform.id))) | |
304 } | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
305 for platform in platforms |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
306 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
307 |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
308 has_reports = False |
250 | 309 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
|
310 has_reports = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
311 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
312 |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
313 if has_reports: |
388
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
314 chart_generators = [] |
391
7801dddec1a1
Sign, another follow-up to [438]. One of these days I should get it right :-(
cmlenz
parents:
390
diff
changeset
|
315 for generator in ReportChartController(self.env).generators: |
388
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
316 for category in generator.get_supported_categories(): |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
317 chart_generators.append({ |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
318 'href': req.href.build(config.name, 'chart/' + category) |
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
319 }) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
320 data['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
|
321 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
|
322 if charts_license: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
323 data['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
|
324 |
214 | 325 page = max(1, int(req.args.get('page', 1))) |
326 more = False | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
327 data['page_number'] = page |
214 | 328 |
360
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
329 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
|
330 if hasattr(repos, 'sync'): |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
331 repos.sync() |
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
332 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
333 builds_per_page = 12 * len(platforms) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
334 idx = 0 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
335 builds = {} |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
336 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
|
337 if idx >= page * builds_per_page: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
338 more = True |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
339 break |
232
b6e4896dc026
Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents:
230
diff
changeset
|
340 elif idx >= (page - 1) * builds_per_page: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
341 builds.setdefault(rev, {}) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
342 builds[rev].setdefault('href', req.href.changeset(rev)) |
230 | 343 if build and build.status != Build.PENDING: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
344 build_data = _get_build_data(self.env, req, build) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
345 build_data['steps'] = [] |
250 | 346 for step in BuildStep.select(self.env, build=build.id, |
347 db=db): | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
348 build_data['steps'].append({ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
349 'name': step.name, |
320 | 350 'description': step.description, |
250 | 351 'duration': datetime.fromtimestamp(step.stopped) - \ |
352 datetime.fromtimestamp(step.started), | |
353 'failed': not step.successful, | |
354 'errors': step.errors, | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
355 'href': build_data['href'] + '#step_' + step.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
356 }) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
357 builds[rev][platform.id] = build_data |
230 | 358 idx += 1 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
359 data['config']['builds'] = builds |
214 | 360 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
361 if page > 1: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
362 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
|
363 prev_href = req.href.build(config.name) |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
364 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
|
365 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
|
366 add_link(req, 'prev', prev_href, 'Previous Page') |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
367 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
|
368 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
|
369 add_link(req, 'next', next_href, 'Next Page') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
370 prevnext_nav(req, 'Page') |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
371 return data |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
372 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
373 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
374 class BuildController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
375 """Renders the build page.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
376 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
377 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
378 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
|
379 report_summarizers = ExtensionPoint(IReportSummarizer) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
380 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
381 # INavigationContributor methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
382 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
383 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
|
384 return 'build' |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
385 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
386 def get_navigation_items(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
387 return [] |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
388 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
389 # IRequestHandler methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
390 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
391 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
|
392 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
|
393 if match: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
394 if match.group(1): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
395 req.args['config'] = match.group(1) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
396 if match.group(2): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
397 req.args['id'] = match.group(2) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
398 return True |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
399 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
400 def process_request(self, req): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
401 req.perm.require('BUILD_VIEW') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
402 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
403 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
404 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
|
405 build = Build.fetch(self.env, build_id, db=db) |
96 | 406 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
|
407 |
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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 |
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
|
413 add_link(req, 'up', req.href.build(build.config), |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
414 'Build Configuration') |
91 | 415 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', |
416 Build.IN_PROGRESS: 'In Progress'} | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
417 data = {'title': 'Build %s - %s' % (build_id, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
418 status2title[build.status]), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
419 'page_mode': 'view_build', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
420 'build': {}} |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
421 config = BuildConfig.fetch(self.env, build.config, db=db) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
422 data['build']['config'] = { |
69 | 423 '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
|
424 'href': req.href.build(config.name) |
69 | 425 } |
426 | |
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
|
427 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
|
428 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
|
429 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
|
430 |
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
|
431 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
|
432 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
|
433 categories = summarizer.get_supported_categories() |
423
8864b3917221
Fix for Python 2.3 incompatibility in display for report summaries. Closes #164.
cmlenz
parents:
411
diff
changeset
|
434 summarizers.update(dict([(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
|
435 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
436 data['build'].update(_get_build_data(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
|
437 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
438 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
|
439 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
|
440 'name': step.name, 'description': step.description, |
123 | 441 '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
|
442 'failed': step.status == BuildStep.FAILURE, |
245
a22ec8fce6c9
Store the reason(s) for build step failure in the database.
cmlenz
parents:
232
diff
changeset
|
443 '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
|
444 '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
|
445 '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
|
446 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
|
447 }) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
448 data['build']['steps'] = steps |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
449 data['build']['can_delete'] = ('BUILD_DELETE' in req.perm) |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
450 |
250 | 451 repos = self.env.get_repository(req.authname) |
452 chgset = repos.get_changeset(build.rev) | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
453 data['build']['chgset_author'] = chgset.author |
250 | 454 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
455 add_script(req, 'bitten/tabset.js') |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
456 add_stylesheet(req, 'bitten/bitten.css') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
457 return 'bitten_build.html', data, 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
|
458 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
459 # ITimelineEventProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
460 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
461 def get_timeline_filters(self, req): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
462 if 'BUILD_VIEW' in req.perm: |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
463 yield ('build', 'Builds') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
464 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
465 def get_timeline_events(self, req, start, stop, filters): |
311 | 466 if 'build' not in filters: |
467 return | |
250 | 468 |
382
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
469 if isinstance(start, datetime): # Trac>=0.11 |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
470 from trac.util.datefmt import to_timestamp |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
471 start = to_timestamp(start) |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
472 stop = to_timestamp(stop) |
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
473 |
311 | 474 add_stylesheet(req, 'bitten/bitten.css') |
475 | |
476 db = self.env.get_db_cnx() | |
477 cursor = db.cursor() | |
478 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name," | |
479 "b.stopped,b.status FROM bitten_build AS b" | |
480 " INNER JOIN bitten_config AS c ON (c.name=b.config) " | |
481 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " | |
482 "WHERE b.stopped>=%s AND b.stopped<=%s " | |
483 "AND b.status IN (%s, %s) ORDER BY b.stopped", | |
484 (start, stop, Build.SUCCESS, Build.FAILURE)) | |
485 | |
486 event_kinds = {Build.SUCCESS: 'successbuild', | |
487 Build.FAILURE: 'failedbuild'} | |
488 for id, config, label, rev, platform, stopped, status in cursor: | |
489 | |
490 errors = [] | |
491 if status == Build.FAILURE: | |
492 for step in BuildStep.select(self.env, build=id, | |
493 status=BuildStep.FAILURE, | |
494 db=db): | |
320 | 495 errors += [(step.name, error) for error |
311 | 496 in step.errors] |
497 | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
498 title = tag('Build of ', tag.em('%s [%s]' % (label, rev)), |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
499 ' on %s %s' % (platform, _status_label[status])) |
311 | 500 message = '' |
501 if req.args.get('format') == 'rss': | |
460
32b61f031df0
Fix a couple of left-over instances of using `env.href` instead of `req.href`. Closes #186. Thanks to Markus Heberling for reporting the issue and providing a patch.
cmlenz
parents:
440
diff
changeset
|
502 href = req.abs_href.build(config, id) |
311 | 503 if errors: |
504 buf = StringIO() | |
505 prev_step = None | |
506 for step, error in errors: | |
507 if step != prev_step: | |
508 if prev_step is not None: | |
509 buf.write('</ul>') | |
321 | 510 buf.write('<p>Step %s failed:</p><ul>' \ |
511 % escape(step)) | |
311 | 512 prev_step = step |
321 | 513 buf.write('<li>%s</li>' % escape(error)) |
311 | 514 buf.write('</ul>') |
320 | 515 message = Markup(buf.getvalue()) |
311 | 516 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
|
517 href = req.href.build(config, id) |
311 | 518 if errors: |
519 steps = [] | |
520 for step, error in errors: | |
521 if step not in steps: | |
522 steps.append(step) | |
488 | 523 steps = [Markup('<em>%s</em>') % step for step in steps] |
311 | 524 if len(steps) < 2: |
525 message = steps[0] | |
526 elif len(steps) == 2: | |
320 | 527 message = Markup(' and ').join(steps) |
311 | 528 elif len(steps) > 2: |
320 | 529 message = Markup(', ').join(steps[:-1]) + ', and ' + \ |
311 | 530 steps[-1] |
488 | 531 message = Markup('Step%s %s failed') % ( |
532 len(steps) != 1 and 's' or '', message | |
533 ) | |
311 | 534 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
|
535 |
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
|
536 # 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
|
537 |
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
|
538 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
|
539 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
|
540 |
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
|
541 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
|
542 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
|
543 |
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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 |
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
|
550 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
|
551 |
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
|
552 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
|
553 |
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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 |
258
77cdef044d48
* Improve build log formatter performance: now only matches strings using the `path:line` format, and checks the existance of files in the repository when they are encountered. Should fix (or at least improve) #54.
cmlenz
parents:
256
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 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
|
567 if summarizer: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
568 tmpl, data = summarizer.render_summary(req, config, build, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
569 step, 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
|
570 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
571 tmpl = data = None |
320 | 572 reports.append({'category': report.category, |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
573 'template': tmpl, 'data': data}) |
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
|
574 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
|
575 |
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
|
576 |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
577 class ReportChartController(Component): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
578 implements(IRequestHandler) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
579 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
580 generators = ExtensionPoint(IReportChartGenerator) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
581 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
582 # IRequestHandler methods |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
583 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
584 def match_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
585 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
|
586 if match: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
587 req.args['config'] = match.group(1) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
588 req.args['category'] = match.group(2) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
589 return True |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
590 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
591 def process_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
592 category = req.args.get('category') |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
593 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
|
594 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
595 for generator in self.generators: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
596 if category in generator.get_supported_categories(): |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
597 tmpl, data = generator.generate_chart_data(req, config, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
598 category) |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
599 break |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
600 else: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
601 raise TracError('Unknown report category "%s"' % category) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
602 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
603 return tmpl, data, 'text/xml' |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
604 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
605 |
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
|
606 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
|
607 """Detects references to files in the build log and renders them as links |
439 | 608 to the repository browser. |
609 """ | |
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
|
610 |
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
|
611 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
|
612 |
439 | 613 _fileref_re = re.compile('(?P<path>[\w.-]+(?:/[\w.-]+)+)(?P<line>(:\d+))?') |
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
|
614 |
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
|
615 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
|
616 """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
|
617 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
|
618 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
|
619 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
|
620 cache = {} |
439 | 621 |
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
|
622 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
|
623 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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 path = posixpath.join(path, part) |
439 | 629 if path not in cache: |
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
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 return m.group(0) |
439 | 638 link = href(config.path, filepath) |
639 if m.group('line'): | |
640 link += '#L' + m.group('line')[1:] | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
641 return Markup(tag.a(m.group(0), href=link)) |
439 | 642 |
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
|
643 def _formatter(step, type, level, message): |
439 | 644 buf = [] |
645 offset = 0 | |
646 for mo in self._fileref_re.finditer(message): | |
647 start, end = mo.span() | |
648 if start > offset: | |
649 buf.append(message[offset:start]) | |
650 buf.append(_replace(mo)) | |
651 offset = end | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
652 if offset < len(message): |
439 | 653 buf.append(message[offset:]) |
654 return Markup("").join(buf) | |
655 | |
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
|
656 return _formatter |