Mercurial > bitten > bitten-test
annotate bitten/trac_ext/web_ui.py @ 120:b63ed684c29c
Show the list of reports generated on the build page.
author | cmlenz |
---|---|
date | Mon, 08 Aug 2005 14:27:20 +0000 |
parents | ecc062d4fd55 |
children | cccfa117e344 |
rev | line source |
---|---|
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
1 # -*- coding: iso8859-1 -*- |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
2 # |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
3 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de> |
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
|
4 # |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
5 # Bitten is free software; you can redistribute it and/or |
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 # modify it under the terms of the GNU General Public License as |
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
|
7 # published by the Free Software Foundation; either version 2 of the |
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
|
8 # License, or (at your option) any later version. |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
9 # |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
10 # Trac is distributed in the hope that it will be useful, |
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
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
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
|
13 # General Public License for more details. |
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 # |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
15 # You should have received a copy of the GNU General Public License |
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
|
16 # along with this program; if not, write to the Free Software |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
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 # |
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
|
19 # Author: Christopher Lenz <cmlenz@gmx.de> |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
20 |
79
87098cbcdc90
* Use default locations when {{{htdocs_dir}}} and {{{templates_dir}}} isn't configured in {{{trac.ini}}}.
cmlenz
parents:
76
diff
changeset
|
21 import os.path |
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 import re |
81
7129b8a2f125
Fix error when running from an installed instance where the {{{htdocs_dir}}} and/or {{{templates_dir}}} options aren't set.
cmlenz
parents:
80
diff
changeset
|
23 import sys |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
24 from time import localtime, strftime |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
25 |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
26 import pkg_resources |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
27 from trac.core import * |
64 | 28 from trac.Timeline import ITimelineEventProvider |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
29 from trac.util import escape, pretty_timedelta |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
30 from trac.web.chrome import INavigationContributor, ITemplateProvider, \ |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
31 add_link, add_stylesheet |
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
|
32 from trac.web.main import IRequestHandler |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
33 from trac.wiki import wiki_to_html |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
34 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, BuildLog |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
35 from bitten.store import ReportStore |
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
|
36 |
96 | 37 |
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
|
38 class ILogFormatter(Interface): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
39 """Extension point interface for components that format build log |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
40 messages.""" |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
41 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
42 def get_formatter(req, build, step, type): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
43 """Return a function that gets called for every log message. |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
44 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
45 The function must take two positional arguments, `level` and `message`, |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
46 and return the formatted message. |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
47 """ |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
48 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
49 |
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
|
50 class BuildModule(Component): |
96 | 51 """Implements the Bitten web interface.""" |
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
|
52 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
53 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider, |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
54 ITemplateProvider) |
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
|
55 |
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
|
56 log_formatters = ExtensionPoint(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
|
57 |
64 | 58 _status_label = {Build.IN_PROGRESS: 'in progress', |
69 | 59 Build.SUCCESS: 'completed', |
64 | 60 Build.FAILURE: 'failed'} |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
61 _level_label = {BuildLog.DEBUG: 'debug', |
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
62 BuildLog.INFO: 'info', |
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
63 BuildLog.WARNING: 'warning', |
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
64 BuildLog.ERROR: 'error'} |
64 | 65 |
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
|
66 # 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
|
67 |
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
|
68 def get_active_navigation_item(self, req): |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
69 return 'build' |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
70 |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
71 def get_navigation_items(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
72 if not req.perm.has_permission('BUILD_VIEW'): |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
73 return |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
74 yield 'mainnav', 'build', \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
75 '<a href="%s" accesskey="5">Build Status</a>' \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
76 % self.env.href.build() |
35
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
77 |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
78 # 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
|
79 |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
80 def match_request(self, req): |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
81 match = re.match(r'/build(?:/([\w.-]+))?(?:/([\d]+))?', 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
|
82 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
|
83 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
84 req.args['config'] = match.group(1) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
85 if match.group(2): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
86 req.args['id'] = match.group(2) |
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
|
87 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
|
88 |
67631e1d4d45
Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff
changeset
|
89 def process_request(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
90 req.perm.assert_permission('BUILD_VIEW') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
91 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
92 action = req.args.get('action') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
93 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
94 id = req.args.get('id') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
95 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
96 if req.method == 'POST': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
97 if config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
98 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
99 self._do_create_platform(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
100 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
101 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
102 if platform_id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
103 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
104 self._do_save_platform(req, config, platform_id) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
105 elif 'delete' in req.args: |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
106 self._do_delete_platforms(req) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
107 self._render_config_form(req, config) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
108 elif 'new' in req.args: |
96 | 109 platform = TargetPlatform(self.env, config=config) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
110 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
111 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
112 self._do_save_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
113 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
114 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
115 self._do_create_config(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
116 else: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
117 if id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
118 self._render_build(req, id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
119 elif config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
120 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
121 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
122 if platform_id: |
96 | 123 platform = TargetPlatform.fetch(self.env, |
124 int(platform_id)) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
125 self._render_platform_form(req, platform) |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
126 elif 'new' in req.args: |
96 | 127 platform = TargetPlatform(self.env, config=config) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
128 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
129 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
130 self._render_config_form(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
131 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
132 self._render_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
133 else: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
134 if action == 'new': |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
135 self._render_config_form(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
136 else: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
137 self._render_overview(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
138 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
139 add_stylesheet(req, 'build.css') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
140 return 'build.cs', None |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
141 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
142 # ITemplatesProvider methods |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
143 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
144 def get_htdocs_dir(self): |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
145 return pkg_resources.resource_filename(__name__, 'htdocs') |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
146 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
147 def get_templates_dir(self): |
99
efc1eed69ba8
Make Bitten deployable in Trac as a [http://peak.telecommunity.com/DevCenter/PythonEggs Python egg].
cmlenz
parents:
98
diff
changeset
|
148 return pkg_resources.resource_filename(__name__, 'templates') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
149 |
64 | 150 # ITimelineEventProvider methods |
151 | |
152 def get_timeline_filters(self, req): | |
153 if req.perm.has_permission('BUILD_VIEW'): | |
154 yield ('build', 'Builds') | |
155 | |
156 def get_timeline_events(self, req, start, stop, filters): | |
157 if 'build' in filters: | |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
158 add_stylesheet(req, 'build.css') |
64 | 159 db = self.env.get_db_cnx() |
160 cursor = db.cursor() | |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
161 cursor.execute("SELECT b.id,b.config,c.label,b.rev,p.name,b.slave," |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
162 "b.stopped,b.status FROM bitten_build AS b" |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
163 " INNER JOIN bitten_config AS c ON (c.name=b.config)" |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
164 " INNER JOIN bitten_platform AS p ON (p.id=b.platform) " |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
165 "WHERE b.stopped>=%s AND b.stopped<=%s " |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
166 "AND b.status IN (%s, %s) ORDER BY b.stopped", |
67 | 167 (start, stop, Build.SUCCESS, Build.FAILURE)) |
65
5f9bcb4966b7
Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents:
64
diff
changeset
|
168 event_kinds = {Build.SUCCESS: 'successbuild', |
5f9bcb4966b7
Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents:
64
diff
changeset
|
169 Build.FAILURE: 'failedbuild'} |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
170 for id, config, label, rev, platform, slave, stopped, status in cursor: |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
171 title = 'Build of <em>%s [%s]</em> by %s (%s) %s' \ |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
172 % (escape(label), escape(rev), escape(slave), |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
173 escape(platform), self._status_label[status]) |
79
87098cbcdc90
* Use default locations when {{{htdocs_dir}}} and {{{templates_dir}}} isn't configured in {{{trac.ini}}}.
cmlenz
parents:
76
diff
changeset
|
174 if req.args.get('format') == 'rss': |
87098cbcdc90
* Use default locations when {{{htdocs_dir}}} and {{{templates_dir}}} isn't configured in {{{trac.ini}}}.
cmlenz
parents:
76
diff
changeset
|
175 href = self.env.abs_href.build(config, id) |
87098cbcdc90
* Use default locations when {{{htdocs_dir}}} and {{{templates_dir}}} isn't configured in {{{trac.ini}}}.
cmlenz
parents:
76
diff
changeset
|
176 else: |
87098cbcdc90
* Use default locations when {{{htdocs_dir}}} and {{{templates_dir}}} isn't configured in {{{trac.ini}}}.
cmlenz
parents:
76
diff
changeset
|
177 href = self.env.href.build(config, id) |
69 | 178 yield event_kinds[status], href, title, stopped, None, '' |
64 | 179 |
180 # Internal methods | |
181 | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
182 def _do_create_config(self, req): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
183 """Create a new build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
184 req.perm.assert_permission('BUILD_CREATE') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
185 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
186 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
187 req.redirect(self.env.href.build()) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
188 |
96 | 189 config = BuildConfig(self.env, name=req.args.get('name'), |
190 path=req.args.get('path', ''), | |
191 label=req.args.get('label', ''), | |
192 active=req.args.has_key('active'), | |
193 description=req.args.get('description')) | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
194 config.insert() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
195 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
196 req.redirect(self.env.href.build(config.name)) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
197 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
198 def _do_save_config(self, req, config_name): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
199 """Save changes to a build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
200 req.perm.assert_permission('BUILD_MODIFY') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
201 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
202 if 'cancel' in req.args: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
203 req.redirect(self.env.href.build(config_name)) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
204 |
96 | 205 config = BuildConfig.fetch(self.env, config_name) |
206 assert config, 'Build configuration "%s" does not exist' % config_name | |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
207 config.name = req.args.get('name') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
208 config.active = req.args.has_key('active') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
209 config.label = req.args.get('label', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
210 config.path = req.args.get('path', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
211 config.description = req.args.get('description', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
212 config.update() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
213 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
214 req.redirect(self.env.href.build(config.name)) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
215 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
216 def _do_create_platform(self, req, config_name): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
217 """Create a new target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
218 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
219 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
220 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
221 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
222 |
96 | 223 platform = TargetPlatform(self.env, config=config_name, |
224 name=req.args.get('name')) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
225 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
226 properties = [int(key[9:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
227 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
228 properties.sort() |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
229 patterns = [int(key[8:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
230 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
231 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
232 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
233 req.args.get('pattern_%d' % pattern)) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
234 for property, pattern in zip(properties, patterns)] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
235 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
236 add_rules = [int(key[9:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
237 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
238 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
239 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
240 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
241 return |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
242 rm_rules = [int(key[8:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
243 if key.startswith('rm_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
244 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
245 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
246 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
247 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
248 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
249 platform.insert() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
250 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
251 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
252 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
253 def _do_delete_platforms(self, req): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
254 """Delete selected target platforms.""" |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
255 req.perm.assert_permission('BUILD_MODIFY') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
256 self.log.debug('_do_delete_platforms') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
257 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
258 db = self.env.get_db_cnx() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
259 for platform_id in [int(id) for id in req.args.get('delete_platform')]: |
96 | 260 platform = TargetPlatform.fetch(self.env, platform_id, db=db) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
261 self.log.info('Deleting target platform %s of configuration %s', |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
262 platform.name, platform.config) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
263 platform.delete(db=db) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
264 db.commit() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
265 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
266 def _do_save_platform(self, req, config_name, platform_id): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
267 """Save changes to a target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
268 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
269 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
270 if 'cancel' in req.args: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
271 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
272 |
96 | 273 platform = TargetPlatform.fetch(self.env, platform_id) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
274 platform.name = req.args.get('name') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
275 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
276 properties = [int(key[9:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
277 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
278 properties.sort() |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
279 patterns = [int(key[8:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
280 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
281 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
282 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
283 req.args.get('pattern_%d' % pattern)) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
284 for property, pattern in zip(properties, patterns)] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
285 |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
286 add_rules = [int(key[9:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
287 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
288 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
289 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
290 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
291 return |
98
1d9dc07acd3d
Use {{{in req.args}}} instead of {{{in req.args.keys()}}}.
cmlenz
parents:
96
diff
changeset
|
292 rm_rules = [int(key[8:]) for key in req.args |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
293 if key.startswith('rm_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
294 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
295 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
296 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
297 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
298 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
299 platform.update() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
300 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
301 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
302 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
303 def _render_overview(self, req): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
304 req.hdf['title'] = 'Build Status' |
45 | 305 configurations = BuildConfig.select(self.env, include_inactive=True) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
306 for idx, config in enumerate(configurations): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
307 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
308 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
309 description = wiki_to_html(description, self.env, req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
310 req.hdf['build.configs.%d' % idx] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
311 'name': config.name, 'label': config.label or config.name, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
312 'path': config.path, 'description': description, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
313 'href': self.env.href.build(config.name) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
314 } |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
315 req.hdf['build.mode'] = 'overview' |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
316 req.hdf['build.can_create'] = req.perm.has_permission('BUILD_CREATE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
317 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
318 def _render_config(self, req, config_name): |
96 | 319 config = BuildConfig.fetch(self.env, config_name) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
320 req.hdf['title'] = 'Build Configuration "%s"' \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
321 % escape(config.label or config.name) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
322 add_link(req, 'up', self.env.href.build(), 'Build Status') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
323 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
324 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
325 description = wiki_to_html(description, self.env, req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
326 req.hdf['build.config'] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
327 'name': config.name, 'label': config.label, 'path': config.path, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
328 'active': config.active, 'description': description, |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
329 'browser_href': self.env.href.browser(config.path), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
330 'can_modify': req.perm.has_permission('BUILD_MODIFY') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
331 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
332 req.hdf['build.mode'] = 'view_config' |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
333 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
334 platforms = TargetPlatform.select(self.env, config=config_name) |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
335 req.hdf['build.platforms'] = [ |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
336 {'name': platform.name, 'id': platform.id} for platform in platforms |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
337 ] |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
338 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
339 repos = self.env.get_repository(req.authname) |
111
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
340 try: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
341 root = repos.get_node(config.path) |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
342 num = 0 |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
343 for idx, (path, rev, chg) in enumerate(root.get_history()): |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
344 prefix = 'build.builds.%d' % rev |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
345 req.hdf[prefix + '.href'] = self.env.href.changeset(rev) |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
346 for build in Build.select(self.env, config=config.name, rev=rev): |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
347 if build.status == Build.PENDING: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
348 continue |
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
|
349 req.hdf['%s.%s' % (prefix, build.platform)] = self._build_to_hdf(req, build) |
111
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
350 if idx > 4: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
351 break |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
352 except TracError, e: |
8d76fd3918a5
Don't just bail on the build configuration page if an invalid repository path is configured.
cmlenz
parents:
99
diff
changeset
|
353 self.log.error('Error accessing repository info', exc_info=True) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
354 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
355 def _render_config_form(self, req, config_name=None): |
96 | 356 config = BuildConfig.fetch(self.env, config_name) |
357 if config: | |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
358 req.perm.assert_permission('BUILD_MODIFY') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
359 req.hdf['build.config'] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
360 'name': config.name, 'label': config.label, 'path': config.path, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
361 'active': config.active, 'description': config.description, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
362 'exists': config.exists |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
363 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
364 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
365 req.hdf['title'] = 'Edit Build Configuration "%s"' \ |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
366 % escape(config.label or config.name) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
367 for idx, platform in enumerate(TargetPlatform.select(self.env, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
368 config_name)): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
369 req.hdf['build.platforms.%d' % idx] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
370 'id': platform.id, 'name': platform.name, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
371 'href': self.env.href.build(config_name, action='edit', |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
372 platform=platform.id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
373 } |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
374 else: |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
375 req.perm.assert_permission('BUILD_CREATE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
376 req.hdf['title'] = 'Create Build Configuration' |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
377 req.hdf['build.mode'] = 'edit_config' |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
378 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
379 def _render_platform_form(self, req, platform): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
380 req.perm.assert_permission('BUILD_MODIFY') |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
381 if platform.exists: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
382 req.hdf['title'] = 'Edit Target Platform "%s"' \ |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
383 % escape(platform.name) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
384 else: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
385 req.hdf['title'] = 'Add Target Platform' |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
386 req.hdf['build.platform'] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
387 'name': platform.name, 'id': platform.id, 'exists': platform.exists, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
388 'rules': [{'property': propname, 'pattern': pattern} |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
389 for propname, pattern in platform.rules] or [('', '')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
390 } |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
391 req.hdf['build.mode'] = 'edit_platform' |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
392 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
393 def _render_build(self, req, build_id): |
96 | 394 build = Build.fetch(self.env, build_id) |
395 assert build, 'Build %s does not exist' % build_id | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
396 add_link(req, 'up', self.env.href.build(build.config), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
397 'Build Configuration') |
91 | 398 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', |
399 Build.IN_PROGRESS: 'In Progress'} | |
69 | 400 req.hdf['title'] = 'Build %s - %s' % (build_id, |
401 status2title[build.status]) | |
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
|
402 req.hdf['build'] = self._build_to_hdf(req, build, include_output=True) |
69 | 403 req.hdf['build.mode'] = 'view_build' |
404 | |
96 | 405 config = BuildConfig.fetch(self.env, build.config) |
69 | 406 req.hdf['build.config'] = { |
407 'name': config.label, | |
408 'href': self.env.href.build(config.name) | |
409 } | |
410 | |
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
|
411 def _build_to_hdf(self, req, build, include_output=False): |
76
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
412 hdf = {'id': build.id, 'name': build.slave, 'rev': build.rev, |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
413 'status': self._status_label[build.status], |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
414 'cls': self._status_label[build.status].replace(' ', '-'), |
ffa1ffd8c7db
* Implement basic slave selection based on configured target platforms. Closes #15.
cmlenz
parents:
74
diff
changeset
|
415 'href': self.env.href.build(build.config, build.id), |
69 | 416 'chgset_href': self.env.href.changeset(build.rev)} |
417 if build.started: | |
418 hdf['started'] = strftime('%x %X', localtime(build.started)) | |
419 hdf['started_delta'] = pretty_timedelta(build.started) | |
420 if build.stopped: | |
421 hdf['stopped'] = strftime('%x %X', localtime(build.stopped)) | |
422 hdf['stopped_delta'] = pretty_timedelta(build.stopped) | |
423 hdf['duration'] = pretty_timedelta(build.stopped, build.started) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
424 hdf['slave'] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
425 'name': build.slave, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
426 'ip_address': build.slave_info.get(Build.IP_ADDRESS), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
427 'os': build.slave_info.get(Build.OS_NAME), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
428 'os.family': build.slave_info.get(Build.OS_FAMILY), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
429 'os.version': build.slave_info.get(Build.OS_VERSION), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
430 'machine': build.slave_info.get(Build.MACHINE), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
431 'processor': build.slave_info.get(Build.PROCESSOR) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
432 } |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
433 db = self.env.get_db_cnx() |
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
|
434 steps = [] |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
435 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
|
436 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
|
437 'name': step.name, 'description': step.description, |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
438 'duration': pretty_timedelta(step.started, step.stopped) |
80
dc1c7fc9b915
Record the output of build steps in the database. See #12. Still need to get better granularity in transmitting the log output from slave to master before #12 can be closed.
cmlenz
parents:
79
diff
changeset
|
439 }) |
112
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
440 if include_output: |
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
441 for log in BuildLog.select(self.env, build=build.id, |
a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
cmlenz
parents:
111
diff
changeset
|
442 step=step.name, db=db): |
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
|
443 formatters = [] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
444 items = [] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
445 for formatter in self.log_formatters: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
446 formatters.append(formatter.get_formatter(req, build, |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
447 step, |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
448 log.type)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
449 for level, message in log.messages: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
450 for format in formatters: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
451 message = format(level, message) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
452 items.append({'level': level, 'message': message}) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
453 steps[-1]['log'] = items |
120
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
454 |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
455 store = ReportStore(self.env) |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
456 reports = [] |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
457 for report in store.retrieve_reports(build, step): |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
458 reports.append({'type': report.attr['type']}) |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
459 steps[-1]['reports'] = reports |
b63ed684c29c
Show the list of reports generated on the build page.
cmlenz
parents:
114
diff
changeset
|
460 |
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
|
461 hdf['steps'] = steps |
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
|
462 |
69 | 463 return hdf |
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
|
464 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
465 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
466 class SourceFileLinkFormatter(Component): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
467 """Finds references to files and directories in the repository in the build |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
468 log and renders them as links to the repository browser.""" |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
469 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
470 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
|
471 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
472 def get_formatter(self, req, build, step, type): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
473 config = BuildConfig.fetch(self.env, build.config) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
474 repos = self.env.get_repository(req.authname) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
475 nodes = [] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
476 def _walk(node): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
477 for child in node.get_entries(): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
478 path = child.path[len(config.path) + 1:] |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
479 pattern = re.compile("([\s'\"])(%s)([\s'\"])" % re.escape(path)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
480 nodes.append((child.path, pattern)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
481 if child.isdir: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
482 _walk(child) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
483 _walk(repos.get_node(config.path, build.rev)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
484 nodes.sort(lambda x, y: -cmp(len(x[0]), len(y[0]))) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
485 |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
486 def _formatter(level, message): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
487 for path, pattern in nodes: |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
488 def _replace(m): |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
489 return '%s<a href="%s">%s</a>%s' % (m.group(1), |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
490 self.env.href.browser(path, rev=build.rev), |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
491 m.group(2), m.group(3)) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
492 message = pattern.sub(_replace, message) |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
493 return message |
ecc062d4fd55
Paths to files and directories in the build log output are rendered as links to the repository browser.
cmlenz
parents:
112
diff
changeset
|
494 return _formatter |