Mercurial > bitten > bitten-test
diff bitten/trac_ext/web_ui.py @ 112:a38eabd4b6e1
* Store build logs in a structured way, for example to highlight messages on the error stream.
* Add basic infrastructure for database upgrades.
author | cmlenz |
---|---|
date | Thu, 04 Aug 2005 20:15:39 +0000 |
parents | 8d76fd3918a5 |
children | ecc062d4fd55 |
line wrap: on
line diff
--- a/bitten/trac_ext/web_ui.py +++ b/bitten/trac_ext/web_ui.py @@ -31,7 +31,7 @@ add_link, add_stylesheet from trac.web.main import IRequestHandler from trac.wiki import wiki_to_html -from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep +from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, BuildLog class BuildModule(Component): @@ -43,6 +43,10 @@ _status_label = {Build.IN_PROGRESS: 'in progress', Build.SUCCESS: 'completed', Build.FAILURE: 'failed'} + _level_label = {BuildLog.DEBUG: 'debug', + BuildLog.INFO: 'info', + BuildLog.WARNING: 'warning', + BuildLog.ERROR: 'error'} # INavigationContributor methods @@ -380,7 +384,7 @@ Build.IN_PROGRESS: 'In Progress'} req.hdf['title'] = 'Build %s - %s' % (build_id, status2title[build.status]) - req.hdf['build'] = self._build_to_hdf(build) + req.hdf['build'] = self._build_to_hdf(build, include_output=True) req.hdf['build.mode'] = 'view_build' config = BuildConfig.fetch(self.env, build.config) @@ -389,7 +393,7 @@ 'href': self.env.href.build(config.name) } - def _build_to_hdf(self, build): + def _build_to_hdf(self, build, include_output=False): hdf = {'id': build.id, 'name': build.slave, 'rev': build.rev, 'status': self._status_label[build.status], 'cls': self._status_label[build.status].replace(' ', '-'), @@ -411,13 +415,19 @@ 'machine': build.slave_info.get(Build.MACHINE), 'processor': build.slave_info.get(Build.PROCESSOR) } + db = self.env.get_db_cnx() steps = [] - for step in BuildStep.select(self.env, build=build.id): + for step in BuildStep.select(self.env, build=build.id, db=db): steps.append({ 'name': step.name, 'description': step.description, - 'duration': pretty_timedelta(step.started, step.stopped), - 'log': step.log + 'duration': pretty_timedelta(step.started, step.stopped) }) + if include_output: + for log in BuildLog.select(self.env, build=build.id, + step=step.name, db=db): + steps[-1]['log'] = [{'level': level, + 'message': message} + for level, message in log.messages] hdf['steps'] = steps return hdf