Mercurial > bitten > bitten-test
annotate bitten/web_ui.py @ 908:56c269e75737 0.6.x
Ported r989 back to 0.6.x branch.
author | cmlenz |
---|---|
date | Wed, 13 Apr 2011 13:25:27 +0000 |
parents | 6b319a8ae32e |
children |
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> |
833 | 4 # Copyright (C) 2007-2010 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 | |
605
c94481bc4646
0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents:
603
diff
changeset
|
13 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
|
14 import re |
763 | 15 import time |
250 | 16 from StringIO import StringIO |
757 | 17 from datetime import datetime |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
18 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
19 import pkg_resources |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
20 from genshi.builder import tag |
751
db5f7388535d
Merge [821,822,823,824,825,826] from trunk. Thanks Walter\!
hodgestar
parents:
724
diff
changeset
|
21 from trac.attachment import AttachmentModule, Attachment |
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
|
22 from trac.core import * |
815 | 23 from trac.config import Option |
629
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
24 from trac.mimeview.api import Context |
884 | 25 from trac.perm import PermissionError |
629
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
26 from trac.resource import Resource |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
27 from trac.timeline import ITimelineEventProvider |
321 | 28 from trac.util import escape, pretty_timedelta, format_datetime, shorten_line, \ |
724 | 29 Markup, arity |
585
87de4513bfdd
0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents:
583
diff
changeset
|
30 from trac.util.datefmt import to_timestamp, to_datetime, utc |
439 | 31 from trac.util.html import html |
571
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
32 from trac.web import IRequestHandler, IRequestFilter, HTTPNotFound |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
33 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
|
34 add_link, add_stylesheet, add_ctxtnav, \ |
884 | 35 prevnext_nav, add_script, add_warning |
36 from trac.versioncontrol import NoSuchChangeset, NoSuchNode | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
37 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
|
38 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
39 from bitten.master import BuildMaster |
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
|
40 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
|
41 BuildLog, Report |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
42 from bitten.queue import collect_changes |
780 | 43 from bitten.util import json |
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
|
44 |
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
|
45 _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
|
46 Build.IN_PROGRESS: 'in progress', |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
47 Build.SUCCESS: 'completed', |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
48 Build.FAILURE: 'failed'} |
506
be811cb659b7
* Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents:
504
diff
changeset
|
49 _status_title = {Build.PENDING: 'Pending', |
be811cb659b7
* Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents:
504
diff
changeset
|
50 Build.IN_PROGRESS: 'In Progress', |
be811cb659b7
* Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents:
504
diff
changeset
|
51 Build.SUCCESS: 'Success', |
be811cb659b7
* Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents:
504
diff
changeset
|
52 Build.FAILURE: 'Failure'} |
763 | 53 _step_status_label = {BuildStep.SUCCESS: 'success', |
54 BuildStep.FAILURE: 'failed', | |
55 BuildStep.IN_PROGRESS: 'in progress'} | |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
56 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
57 def _get_build_data(env, req, build): |
876 | 58 platform = TargetPlatform.fetch(env, build.platform) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
59 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
|
60 'status': _status_label[build.status], |
876 | 61 'platform': getattr(platform, 'name', 'unknown'), |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
62 '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
|
63 '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
|
64 '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
|
65 if build.started: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 if build.stopped: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 data['slave'] = { |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
74 'name': build.slave, |
250 | 75 '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
|
76 '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
|
77 '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
|
78 '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
|
79 '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
|
80 '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
|
81 } |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
82 return data |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
83 |
884 | 84 def _has_permission(perm, repos, path, rev=None, raise_error=False): |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
85 if hasattr(repos, 'authz'): |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
86 if not repos.authz.has_permission(path): |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
87 if not raise_error: |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
88 return False |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
89 repos.authz.assert_permission(path) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
90 else: |
884 | 91 node = repos.get_node(path, rev) |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
92 if not node.can_view(perm): |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
93 if not raise_error: |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
94 return False |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
95 raise PermissionError('BROWSER_VIEW', node.resource) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
96 return True |
318 | 97 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
98 class BittenChrome(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
99 """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
|
100 |
320 | 101 implements(INavigationContributor, ITemplateProvider) |
64 | 102 |
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 # 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
|
104 |
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 def get_active_navigation_item(self, req): |
590
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
106 pass |
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
|
107 |
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 def get_navigation_items(self, req): |
316 | 109 """Return the navigation item for access the build status overview from |
110 the Trac navigation bar.""" | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
111 if 'BUILD_VIEW' in req.perm: |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
112 status = '' |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
113 if BuildMaster(self.env).quick_status: |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
114 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
115 assert repos, 'No "(default)" Repository: Add a repository ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
116 'or alias named "(default)" to Trac.' |
763 | 117 for config in BuildConfig.select(self.env, |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
118 include_inactive=False): |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
119 prev_rev = None |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
120 for platform, rev, build in collect_changes(repos, config): |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
121 if rev != prev_rev: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
122 if prev_rev is not None: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
123 break |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
124 prev_rev = rev |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
125 if build: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
126 build_data = _get_build_data(self.env, req, build) |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
127 if build_data['status'] == 'failed': |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
128 status='bittenfailed' |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
129 break |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
130 if build_data['status'] == 'in progress': |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
131 status='bitteninprogress' |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
132 elif not status: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
133 if (build_data['status'] == 'completed'): |
763 | 134 status='bittencompleted' |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
135 if not status: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
136 status='bittenpending' |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
137 yield ('mainnav', 'build', |
763 | 138 tag.a('Build Status', href=req.href.build(), accesskey=5, |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
139 class_=status)) |
320 | 140 |
141 # ITemplatesProvider methods | |
142 | |
143 def get_htdocs_dirs(self): | |
144 """Return the directories containing static resources.""" | |
145 return [('bitten', pkg_resources.resource_filename(__name__, 'htdocs'))] | |
146 | |
147 def get_templates_dirs(self): | |
148 """Return the directories containing templates.""" | |
149 return [pkg_resources.resource_filename(__name__, 'templates')] | |
150 | |
151 | |
152 class BuildConfigController(Component): | |
153 """Implements the web interface for build configurations.""" | |
154 | |
590
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
155 implements(IRequestHandler, IRequestFilter, INavigationContributor) |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
156 |
815 | 157 # Configuration options |
158 | |
159 chart_style = Option('bitten', 'chart_style', 'height: 220px; width: 220px;', doc= | |
160 """Style attribute for charts. Mostly useful for setting the height and width.""") | |
161 | |
590
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
162 # INavigationContributor methods |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
163 |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
164 def get_active_navigation_item(self, req): |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
165 return 'build' |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
166 |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
167 def get_navigation_items(self, req): |
1e01ab1acd60
0.6dev: Fix highlighting for active navigation. Closes #343.
osimons
parents:
585
diff
changeset
|
168 return [] |
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
|
169 |
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
|
170 # 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
|
171 |
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
|
172 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
|
173 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
|
174 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
|
175 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
176 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
|
177 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
|
178 |
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
|
179 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
|
180 req.perm.require('BUILD_VIEW') |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
181 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
182 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
|
183 view = req.args.get('view') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
184 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
185 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
186 if config: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
187 data = self._render_config(req, config) |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
188 elif view == 'inprogress': |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
189 data = self._render_inprogress(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
190 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
191 data = self._render_overview(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
192 |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
193 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
|
194 return 'bitten_config.html', data, None |
64 | 195 |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
196 # IRequestHandler methods |
763 | 197 |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
198 def pre_process_request(self, req, handler): |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
199 return handler |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
200 |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
201 def post_process_request(self, req, template, data, content_type): |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
202 if template: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
203 add_stylesheet(req, 'bitten/bitten.css') |
763 | 204 |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
528
diff
changeset
|
205 return template, data, content_type |
763 | 206 |
64 | 207 # Internal methods |
208 | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 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
|
213 show_all = True |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
214 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
|
215 |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
216 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
217 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
218 'named "(default)" to Trac.' |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
219 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
220 configs = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
221 for config in BuildConfig.select(self.env, include_inactive=show_all): |
884 | 222 rev = config.max_rev or repos.youngest_rev |
223 try: | |
224 if not _has_permission(req.perm, repos, config.path, rev=rev): | |
225 continue | |
226 except NoSuchNode: | |
227 add_warning(req, "Configuration '%s' points to non-existing " | |
228 "path '/%s' at revision '%s'. Configuration skipped." \ | |
229 % (config.name, config.path, rev)) | |
561
8ffe90404a8c
hide build configurations that user does not have rights to access in repository (silk) - fixes #384
dfraser
parents:
557
diff
changeset
|
230 continue |
8ffe90404a8c
hide build configurations that user does not have rights to access in repository (silk) - fixes #384
dfraser
parents:
557
diff
changeset
|
231 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
232 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
233 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
234 description = wiki_to_html(description, self.env, req) |
504 | 235 |
236 platforms_data = [] | |
237 for platform in TargetPlatform.select(self.env, config=config.name): | |
238 pd = { 'name': platform.name, | |
239 'id': platform.id, | |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
240 'builds_pending': len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
241 config=config.name, status=Build.PENDING, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
242 platform=platform.id))), |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
243 'builds_inprogress': len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
244 config=config.name, status=Build.IN_PROGRESS, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
245 platform=platform.id))) |
504 | 246 } |
247 platforms_data.append(pd) | |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
248 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
249 config_data = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
250 '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
|
251 '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
|
252 'description': description, |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
253 'builds_pending' : len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
254 config=config.name, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
255 status=Build.PENDING))), |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
256 'builds_inprogress' : len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
257 config=config.name, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
258 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
|
259 'href': req.href.build(config.name), |
504 | 260 'builds': [], |
261 'platforms': platforms_data | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
262 } |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 |
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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 'id': rev, 'href': req.href.changeset(rev), |
836 | 274 'display_rev': repos.normalize_rev(rev), |
320 | 275 '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
|
276 '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
|
277 'message': wiki_to_oneliner( |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
278 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
|
279 } |
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
|
280 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
|
281 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
|
282 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
|
283 if build: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
284 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
|
285 build_data['platform'] = platform.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
286 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
|
287 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
288 config_data['builds'].append({ |
320 | 289 '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
|
290 }) |
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
|
291 |
751
db5f7388535d
Merge [821,822,823,824,825,826] from trunk. Thanks Walter\!
hodgestar
parents:
724
diff
changeset
|
292 data['configs'] = sorted(configs, key=lambda x:x['label'].lower()) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
293 data['page_mode'] = 'overview' |
504 | 294 |
295 in_progress_builds = Build.select(self.env, status=Build.IN_PROGRESS) | |
296 pending_builds = Build.select(self.env, status=Build.PENDING) | |
297 | |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
298 data['builds_pending'] = len(list(pending_builds)) |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
299 data['builds_inprogress'] = len(list(in_progress_builds)) |
504 | 300 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
423
diff
changeset
|
301 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
|
302 'In Progress Builds') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
303 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
|
304 req.href.build(view='inprogress')) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
305 return data |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
306 |
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
|
307 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
|
308 data = {'title': 'In Progress Builds', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
309 '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
|
310 |
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
|
311 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
|
312 |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
313 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
314 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
315 'named "(default)" to Trac.' |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
316 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
317 configs = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
318 for config in BuildConfig.select(self.env, include_inactive=False): |
884 | 319 rev = config.max_rev or repos.youngest_rev |
320 try: | |
321 if not _has_permission(req.perm, repos, config.path, rev=rev): | |
322 continue | |
323 except NoSuchNode: | |
324 add_warning(req, "Configuration '%s' points to non-existing " | |
325 "path '/%s' at revision '%s'. Configuration skipped." \ | |
326 % (config.name, config.path, rev)) | |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
327 continue |
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
328 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 |
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
|
333 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
|
334 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
|
335 |
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
|
336 current_builds = 0 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
337 builds = [] |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
338 # sort correctly by revision. |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
339 for build in sorted(in_progress_builds, |
876 | 340 cmp=lambda x, y: int(y.rev_time) - int(x.rev_time)): |
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
|
341 rev = build.rev |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
342 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
|
343 build_data['rev'] = rev |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
344 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
|
345 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
|
346 build_data['platform'] = platform.name |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
347 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
|
348 |
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
|
349 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
|
350 build_data['steps'].append({ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
351 'name': step.name, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
352 'description': step.description, |
763 | 353 'duration': to_datetime(step.stopped or int(time.time()), utc) - \ |
585
87de4513bfdd
0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents:
583
diff
changeset
|
354 to_datetime(step.started, utc), |
763 | 355 'status': _step_status_label[step.status], |
356 'cls': _step_status_label[step.status].replace(' ', '-'), | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
357 'errors': step.errors, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
358 '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
|
359 }) |
381
166dcdb9269e
New In-Progress Builds Page, which lists the current builds that are being processed by slaves. Accessible from the main build page.
wbell
parents:
379
diff
changeset
|
360 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
361 builds.append(build_data) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
362 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
|
363 |
763 | 364 if current_builds == 0: |
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
|
365 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
|
366 |
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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 '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
|
372 '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
|
373 '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
|
374 '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
|
375 'builds': builds |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
376 }) |
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
|
377 |
763 | 378 data['configs'] = sorted(configs, key=lambda x:x['label'].lower()) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
379 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
|
380 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
381 def _render_config(self, req, config_name): |
250 | 382 db = self.env.get_db_cnx() |
383 | |
384 config = BuildConfig.fetch(self.env, config_name, db=db) | |
571
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
385 if not config: |
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
386 raise HTTPNotFound("Build configuration '%s' does not exist." \ |
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
387 % config_name) |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
388 |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
389 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
390 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
391 'named "(default)" to Trac.' |
884 | 392 rev = config.max_rev or repos.youngest_rev |
393 try: | |
394 _has_permission(req.perm, repos, config.path, rev=rev, | |
395 raise_error=True) | |
396 except NoSuchNode: | |
397 raise TracError("Permission checking against repository path %s " | |
398 "at revision %s failed." % (config.path, rev)) | |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
399 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
400 data = {'title': 'Build Configuration "%s"' \ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
401 % config.label or config.name, |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
402 '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
|
403 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
|
404 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
405 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
406 description = wiki_to_html(description, self.env, req) |
504 | 407 |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
408 pending_builds = list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
409 config=config.name, status=Build.PENDING)) |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
410 inprogress_builds = list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
411 config=config.name, status=Build.IN_PROGRESS)) |
504 | 412 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
413 data['config'] = { |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
414 'name': config.name, 'label': config.label, 'path': config.path, |
250 | 415 '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
|
416 'min_rev_href': req.href.changeset(config.min_rev), |
250 | 417 '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
|
418 '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
|
419 'active': config.active, 'description': description, |
504 | 420 'browser_href': req.href.browser(config.path), |
421 'builds_pending' : len(pending_builds), | |
638
74237f60f8a9
0.6dev: Improving builds overview page layout, take 2. Re-closing #430.
osimons
parents:
637
diff
changeset
|
422 'builds_inprogress' : len(inprogress_builds) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
423 } |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
424 |
629
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
425 context = Context.from_request(req, config.resource) |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
426 data['context'] = context |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
427 data['config']['attachments'] = AttachmentModule(self.env).attachment_data(context) |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
428 |
250 | 429 platforms = list(TargetPlatform.select(self.env, config=config_name, |
430 db=db)) | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
431 data['config']['platforms'] = [ |
504 | 432 { 'name': platform.name, |
763 | 433 'id': platform.id, |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
434 'builds_pending': len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
435 config=config.name, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
436 status=Build.PENDING, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
437 platform=platform.id))), |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
438 'builds_inprogress': len(list(Build.select(self.env, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
439 config=config.name, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
440 status=Build.IN_PROGRESS, |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
441 platform=platform.id))) |
504 | 442 } |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
443 for platform in platforms |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
444 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
445 |
197
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
446 has_reports = False |
250 | 447 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
|
448 has_reports = True |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
449 break |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
450 |
d72c0587fae9
* Don't schedule/display builds for revisions where the repository directory is empty. Fixes #46.
cmlenz
parents:
196
diff
changeset
|
451 if has_reports: |
388
3ba9430a5d87
Fix for hardcoded chart generators in UI. Closes #153.
cmlenz
parents:
382
diff
changeset
|
452 chart_generators = [] |
757 | 453 report_categories = list(self._report_categories_for_config(config)) |
763 | 454 for generator in ReportChartController(self.env).generators: |
455 for category in generator.get_supported_categories(): | |
757 | 456 if category in report_categories: |
457 chart_generators.append({ | |
774 | 458 'href': req.href.build(config.name, 'chart/' + category), |
459 'category': category, | |
815 | 460 'style': self.config.get('bitten', 'chart_style'), |
757 | 461 }) |
763 | 462 data['config']['charts'] = chart_generators |
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
|
463 |
214 | 464 page = max(1, int(req.args.get('page', 1))) |
465 more = False | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
466 data['page_number'] = page |
214 | 467 |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
468 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
469 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
470 'named "(default)" to Trac.' |
360
5bc81e597352
Fix incompatibility with a change to the versioncontrol layer in Trac 0.10.3
cmlenz
parents:
328
diff
changeset
|
471 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
472 builds_per_page = 12 * len(platforms) |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
473 idx = 0 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
474 builds = {} |
813 | 475 revisions = [] |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
476 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
|
477 if idx >= page * builds_per_page: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
478 more = True |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
479 break |
232
b6e4896dc026
Fix regression introduced in [239]: first build was being skipped on build configuration page.
cmlenz
parents:
230
diff
changeset
|
480 elif idx >= (page - 1) * builds_per_page: |
813 | 481 if rev not in builds: |
482 revisions.append(rev) | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
483 builds.setdefault(rev, {}) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
484 builds[rev].setdefault('href', req.href.changeset(rev)) |
836 | 485 builds[rev].setdefault('display_rev', repos.normalize_rev(rev)) |
230 | 486 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
|
487 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
|
488 build_data['steps'] = [] |
250 | 489 for step in BuildStep.select(self.env, build=build.id, |
490 db=db): | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
491 build_data['steps'].append({ |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
492 'name': step.name, |
320 | 493 'description': step.description, |
763 | 494 'duration': to_datetime(step.stopped or int(time.time()), utc) - \ |
585
87de4513bfdd
0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents:
583
diff
changeset
|
495 to_datetime(step.started, utc), |
763 | 496 'status': _step_status_label[step.status], |
497 'cls': _step_status_label[step.status].replace(' ', '-'), | |
498 | |
250 | 499 'errors': step.errors, |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
500 '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
|
501 }) |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
502 builds[rev][platform.id] = build_data |
230 | 503 idx += 1 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
504 data['config']['builds'] = builds |
813 | 505 data['config']['revisions'] = revisions |
214 | 506 |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
507 if page > 1: |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
508 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
|
509 prev_href = req.href.build(config.name) |
228
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
510 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
|
511 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
|
512 add_link(req, 'prev', prev_href, 'Previous Page') |
a8c9dd7e3f71
* Cleanup and documentation for the `BuildQueue` class added in [236].
cmlenz
parents:
219
diff
changeset
|
513 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
|
514 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
|
515 add_link(req, 'next', next_href, 'Next Page') |
724 | 516 if arity(prevnext_nav) == 4: # Trac 0.12 compat, see #450 |
517 prevnext_nav(req, 'Previous Page', 'Next Page') | |
518 else: | |
519 prevnext_nav (req, 'Page') | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
520 return data |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
521 |
757 | 522 def _report_categories_for_config(self, config): |
523 """Yields the categories of reports that exist for active builds | |
524 of this configuration. | |
525 """ | |
763 | 526 |
757 | 527 db = self.env.get_db_cnx() |
528 cursor = db.cursor() | |
763 | 529 |
757 | 530 cursor.execute("""SELECT DISTINCT report.category as category |
763 | 531 FROM bitten_build AS build |
757 | 532 JOIN bitten_report AS report ON (report.build=build.id) |
763 | 533 WHERE build.config=%s AND build.rev_time >= %s AND build.rev_time <= %s""", |
534 (config.name, | |
757 | 535 config.min_rev_time(self.env), |
536 config.max_rev_time(self.env))) | |
537 | |
538 for (category,) in cursor: | |
539 yield category | |
540 | |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
541 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
542 class BuildController(Component): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
543 """Renders the build page.""" |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
544 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
545 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
546 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
|
547 report_summarizers = ExtensionPoint(IReportSummarizer) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
548 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
549 # INavigationContributor methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
550 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
551 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
|
552 return 'build' |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
553 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
554 def get_navigation_items(self, req): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
555 return [] |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
556 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
557 # IRequestHandler methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
558 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
559 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
|
560 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
|
561 if match: |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
562 if match.group(1): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
563 req.args['config'] = match.group(1) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
564 if match.group(2): |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
565 req.args['id'] = match.group(2) |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
566 return True |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
567 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
568 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
|
569 req.perm.require('BUILD_VIEW') |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
570 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
571 db = self.env.get_db_cnx() |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
572 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
|
573 build = Build.fetch(self.env, build_id, db=db) |
571
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
574 if not build: |
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
575 raise HTTPNotFound("Build '%s' does not exist." \ |
bed75f6c3e57
0.6dev: Raise regular `HTTPNotFound` (404) if build or configuration is not found (instead of raising ?ttributeError` error with traceback).
osimons
parents:
562
diff
changeset
|
576 % build_id) |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
577 |
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
|
578 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
|
579 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
|
580 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
|
581 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
|
582 |
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
|
583 add_link(req, 'up', req.href.build(build.config), |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
584 'Build Configuration') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
585 data = {'title': 'Build %s - %s' % (build_id, |
506
be811cb659b7
* Renamed `status2title` to `_status_title` and made it a global variable alongside `_status_label`
dfraser
parents:
504
diff
changeset
|
586 _status_title[build.status]), |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
587 'page_mode': 'view_build', |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
588 'build': {}} |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
589 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
|
590 data['build']['config'] = { |
583
f916b88926f5
0.6dev: If configuration display label is deleted, no name would show and the build UI would fold across a couple of lines. This should see to it that the configuration always has a name available.
osimons
parents:
571
diff
changeset
|
591 'name': config.label or config.name, |
376
05c684ceb8c6
Use `req.href` instead of `env.href` as that works much better in Trac>=0.10. That also means Trac 0.9 is no longer supported.
cmlenz
parents:
362
diff
changeset
|
592 'href': req.href.build(config.name) |
69 | 593 } |
594 | |
629
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
595 context = Context.from_request(req, build.resource) |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
596 data['context'] = context |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
597 data['build']['attachments'] = AttachmentModule(self.env).attachment_data(context) |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
598 |
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
|
599 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
|
600 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
|
601 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
|
602 |
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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
608 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
|
609 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
610 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
|
611 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
|
612 'name': step.name, 'description': step.description, |
763 | 613 'duration': pretty_timedelta(step.started, step.stopped or int(time.time())), |
614 'status': _step_status_label[step.status], | |
615 'cls': _step_status_label[step.status].replace(' ', '-'), | |
245
a22ec8fce6c9
Store the reason(s) for build step failure in the database.
cmlenz
parents:
232
diff
changeset
|
616 '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
|
617 '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
|
618 '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
|
619 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
|
620 }) |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
621 data['build']['steps'] = steps |
592
4848d9b7a3e5
0.6dev: Removing 'Invalidate build' button when the build is 'pending' (and nothing further to really invalidate). See #332.
osimons
parents:
591
diff
changeset
|
622 data['build']['can_delete'] = ('BUILD_DELETE' in req.perm \ |
4848d9b7a3e5
0.6dev: Removing 'Invalidate build' button when the build is 'pending' (and nothing further to really invalidate). See #332.
osimons
parents:
591
diff
changeset
|
623 and build.status != build.PENDING) |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
624 |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
625 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
626 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
627 'named "(default)" to Trac.' |
884 | 628 _has_permission(req.perm, repos, config.path, rev=build.rev, raise_error=True) |
250 | 629 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
|
630 data['build']['chgset_author'] = chgset.author |
836 | 631 data['build']['display_rev'] = repos.normalize_rev(build.rev) |
250 | 632 |
636
21902b481ee7
0.6dev: Inline display of error and failure details in 'Test Results' summary table.
osimons
parents:
629
diff
changeset
|
633 add_script(req, 'common/js/folding.js') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
634 add_script(req, 'bitten/tabset.js') |
774 | 635 add_script(req, 'bitten/jquery.flot.js') |
164
a9cddfae3c09
Adapt to Trac [http://projects.edgewall.com/trac/changeset/2132 r2132].
cmlenz
parents:
163
diff
changeset
|
636 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
|
637 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
|
638 |
141
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
639 # ITimelineEventProvider methods |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
640 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
641 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
|
642 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
|
643 yield ('build', 'Builds') |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
644 |
0e21778c04ef
Refactoring: split up the components and templates that render the web interface.
cmlenz
parents:
139
diff
changeset
|
645 def get_timeline_events(self, req, start, stop, filters): |
311 | 646 if 'build' not in filters: |
647 return | |
250 | 648 |
629
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
649 # Attachments (will be rendered by attachment module) |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
650 for event in AttachmentModule(self.env).get_timeline_events( |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
651 req, Resource('build'), start, stop): |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
652 yield event |
f3bb52da9e3c
0.6dev: Adding support for attachments to configurations and build - full web implementation that mirrors what is available in Ticket and Wiki. Also added a new generic `<attach/>` command that enables attaching files to be part of a recipe and uploaded by slaves as part of build.
osimons
parents:
605
diff
changeset
|
653 |
585
87de4513bfdd
0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents:
583
diff
changeset
|
654 start = to_timestamp(start) |
87de4513bfdd
0.6dev: Cleaning remaining 'frontend' datetime code - at least down to all code that interface with the various `model` classes that still only works with timestamps for input and output. See #85.
osimons
parents:
583
diff
changeset
|
655 stop = to_timestamp(stop) |
382
2078b20186cf
Trac 0.11 compatibility fix in timeline event provider.
cmlenz
parents:
381
diff
changeset
|
656 |
311 | 657 add_stylesheet(req, 'bitten/bitten.css') |
658 | |
659 db = self.env.get_db_cnx() | |
660 cursor = db.cursor() | |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
661 cursor.execute("SELECT b.id,b.config,c.label,c.path, b.rev,p.name," |
311 | 662 "b.stopped,b.status FROM bitten_build AS b" |
663 " INNER JOIN bitten_config AS c ON (c.name=b.config) " | |
664 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " | |
665 "WHERE b.stopped>=%s AND b.stopped<=%s " | |
666 "AND b.status IN (%s, %s) ORDER BY b.stopped", | |
667 (start, stop, Build.SUCCESS, Build.FAILURE)) | |
668 | |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
669 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
670 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
671 'named "(default)" to Trac.' |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
672 |
311 | 673 event_kinds = {Build.SUCCESS: 'successbuild', |
674 Build.FAILURE: 'failedbuild'} | |
675 | |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
676 for id_, config, label, path, rev, platform, stopped, status in cursor: |
884 | 677 if not _has_permission(req.perm, repos, path, rev=rev): |
562
a8c84285e67a
Complete rights restrictions for build configs etc - see #384. Also enhance tests to work with this code (but don't yet check that rights are restricted properly)
dfraser
parents:
561
diff
changeset
|
678 continue |
311 | 679 errors = [] |
680 if status == Build.FAILURE: | |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
681 for step in BuildStep.select(self.env, build=id_, |
311 | 682 status=BuildStep.FAILURE, |
683 db=db): | |
320 | 684 errors += [(step.name, error) for error |
311 | 685 in step.errors] |
836 | 686 display_rev = repos.normalize_rev(rev) |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
687 yield (event_kinds[status], to_datetime(stopped, utc), None, |
836 | 688 (id_, config, label, display_rev, platform, status, |
689 errors)) | |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
690 |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
691 def render_timeline_event(self, context, field, event): |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
692 id_, config, label, rev, platform, status, errors = event[3] |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
693 |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
694 if field == 'url': |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
695 return context.href.build(config, id_) |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
696 |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
697 elif field == 'title': |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
698 return tag('Build of ', tag.em('%s [%s]' % (label, rev)), |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
699 ' on %s %s' % (platform, _status_label[status])) |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
700 |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
701 elif field == 'description': |
311 | 702 message = '' |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
703 if context.req.args.get('format') == 'rss': |
311 | 704 if errors: |
705 buf = StringIO() | |
706 prev_step = None | |
707 for step, error in errors: | |
708 if step != prev_step: | |
709 if prev_step is not None: | |
710 buf.write('</ul>') | |
321 | 711 buf.write('<p>Step %s failed:</p><ul>' \ |
712 % escape(step)) | |
311 | 713 prev_step = step |
321 | 714 buf.write('<li>%s</li>' % escape(error)) |
311 | 715 buf.write('</ul>') |
320 | 716 message = Markup(buf.getvalue()) |
311 | 717 else: |
718 if errors: | |
719 steps = [] | |
720 for step, error in errors: | |
721 if step not in steps: | |
722 steps.append(step) | |
488 | 723 steps = [Markup('<em>%s</em>') % step for step in steps] |
311 | 724 if len(steps) < 2: |
725 message = steps[0] | |
726 elif len(steps) == 2: | |
320 | 727 message = Markup(' and ').join(steps) |
311 | 728 elif len(steps) > 2: |
320 | 729 message = Markup(', ').join(steps[:-1]) + ', and ' + \ |
311 | 730 steps[-1] |
488 | 731 message = Markup('Step%s %s failed') % ( |
644
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
732 len(steps) != 1 and 's' or '', message) |
9331ab08000f
0.6dev: Switching to use Trac 0.11 Timeline API that is more efficient with regards to cursor usage. See #269.
osimons
parents:
643
diff
changeset
|
733 return 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
|
734 |
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
|
735 # 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
|
736 |
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
|
737 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
|
738 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
|
739 |
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
|
740 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
|
741 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
|
742 |
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
|
743 build.slave = None |
763 | 744 build.started = 0 |
745 build.stopped = 0 | |
746 build.last_activity = 0 | |
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
|
747 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
|
748 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
|
749 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
|
750 |
751
db5f7388535d
Merge [821,822,823,824,825,826] from trunk. Thanks Walter\!
hodgestar
parents:
724
diff
changeset
|
751 Attachment.delete_all(self.env, 'build', build.resource.id, db) |
db5f7388535d
Merge [821,822,823,824,825,826] from trunk. Thanks Walter\!
hodgestar
parents:
724
diff
changeset
|
752 |
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
|
753 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
|
754 |
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
|
755 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
|
756 |
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
|
757 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
|
758 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
|
759 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
|
760 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
|
761 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
|
762 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
|
763 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
|
764 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
|
765 |
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
|
766 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
|
767 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
|
768 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
|
769 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
|
770 if summarizer: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
771 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
|
772 step, report.category) |
757 | 773 reports.append({'category': report.category, |
774 '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
|
775 else: |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
493
diff
changeset
|
776 tmpl = data = None |
161
4677161d2ae9
Reports can now be "summarized" on the build results page, with special components rendering summary HTML fragments for specific report types. The summaries are displayed as tabs next to the log of the build step. Currently summarizers for test results and code coverage exist.
cmlenz
parents:
147
diff
changeset
|
777 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
|
778 |
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
|
779 |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
780 class ReportChartController(Component): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
781 implements(IRequestHandler) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
782 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
783 generators = ExtensionPoint(IReportChartGenerator) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
784 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
785 # IRequestHandler methods |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
786 def match_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
787 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
|
788 if match: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
789 req.args['config'] = match.group(1) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
790 req.args['category'] = match.group(2) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
791 return True |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
792 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
793 def process_request(self, req): |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
794 category = req.args.get('category') |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
795 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
|
796 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
797 for generator in self.generators: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
798 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
|
799 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
|
800 category) |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
801 break |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
802 else: |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
803 raise TracError('Unknown report category "%s"' % category) |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
804 |
780 | 805 data['dumps'] = json.to_json |
774 | 806 |
807 return tmpl, data, 'text/plain' | |
409
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
808 |
5786700df0c7
Moved/restructured the modules implementing report chart generators and report summarizers.
cmlenz
parents:
408
diff
changeset
|
809 |
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
|
810 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
|
811 """Detects references to files in the build log and renders them as links |
439 | 812 to the repository browser. |
813 """ | |
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
|
814 |
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
|
815 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
|
816 |
593
99831ab37fd3
0.6dev: Making source-linking work also for Windows-style file references (as output by Windows slaves). Thanks to Doug Patterson for updated regexp.
osimons
parents:
592
diff
changeset
|
817 _fileref_re = re.compile(r'(?P<prefix>-[A-Za-z])?(?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
|
818 |
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
|
819 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
|
820 """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
|
821 config = BuildConfig.fetch(self.env, name=build.config) |
805
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
822 repos = self.env.get_repository(authname=req.authname) |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
823 assert repos, 'No "(default)" Repository: Add a repository or alias ' \ |
4a1e2d555626
0.6dev: Merged [882] from trunk. Basic Trac 0.12 support.
osimons
parents:
795
diff
changeset
|
824 'named "(default)" to Trac.' |
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
|
825 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
|
826 cache = {} |
439 | 827 |
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
|
828 def _replace(m): |
605
c94481bc4646
0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents:
603
diff
changeset
|
829 filepath = posixpath.normpath(m.group('path').replace('\\', '/')) |
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
|
830 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
|
831 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
|
832 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
|
833 for part in parts: |
605
c94481bc4646
0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents:
603
diff
changeset
|
834 path = posixpath.join(path, part) |
439 | 835 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
|
836 try: |
605
c94481bc4646
0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents:
603
diff
changeset
|
837 full_path = posixpath.join(config.path, path) |
c94481bc4646
0.6dev: Reverting [677] as many of these paths are also used for URLs, and hadn't considered this change enough. No major point in changing code that already works well, so simply reverting seems the best idea...
osimons
parents:
603
diff
changeset
|
838 full_path = posixpath.normpath(full_path) |
591
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
839 if full_path.startswith(config.path + "/") \ |
87f87c756dca
0.6dev: Just cleaning some tabs + very long code lines in `web_ui.py`.
osimons
parents:
590
diff
changeset
|
840 or full_path == config.path: |
528
f3bf55de8a34
Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents:
506
diff
changeset
|
841 repos.get_node(full_path, |
f3bf55de8a34
Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents:
506
diff
changeset
|
842 build.rev) |
f3bf55de8a34
Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents:
506
diff
changeset
|
843 cache[path] = True |
f3bf55de8a34
Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents:
506
diff
changeset
|
844 else: |
f3bf55de8a34
Prevent path highlighting from passing non-canonical paths to svn:
dfraser
parents:
506
diff
changeset
|
845 cache[path] = False |
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
|
846 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
|
847 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
|
848 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
|
849 return m.group(0) |
439 | 850 link = href(config.path, filepath) |
851 if m.group('line'): | |
852 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
|
853 return Markup(tag.a(m.group(0), href=link)) |
439 | 854 |
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
|
855 def _formatter(step, type, level, message): |
439 | 856 buf = [] |
857 offset = 0 | |
858 for mo in self._fileref_re.finditer(message): | |
859 start, end = mo.span() | |
860 if start > offset: | |
861 buf.append(message[offset:start]) | |
862 buf.append(_replace(mo)) | |
863 offset = end | |
440
e660687ac89c
Follow-up fix to [486]: trailing chars in auto-linked log messages was getting removed.
cmlenz
parents:
439
diff
changeset
|
864 if offset < len(message): |
439 | 865 buf.append(message[offset:]) |
866 return Markup("").join(buf) | |
867 | |
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
|
868 return _formatter |