diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-10-04 18:27:17 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-10-05 21:18:08 +0300 |
commit | bab8f1a382e65ffec583bda5642b43091ecaa3a3 (patch) | |
tree | bfc9cdbb91c7d284ddd1f8bddac72c381fd40602 /ick | |
parent | 62efe176f85db8e33f61b8e6c2680de79ee10b78 (diff) | |
download | ick-bab8f1a382e65ffec583bda5642b43091ecaa3a3.tar.gz |
Use ttystatus progress reporting to terminal
This started as a bug fix for build logs: each build log would contain
the log for all later builds as well, because of a silly bug. However,
as I was fixing that, I realised that I don't particularly want to
flood stdout with build logs. I'd rather have sensible progress
reporting. Thus, this commit changes things so that ttystatus is used
for progress reporting to the terminal, and each build's log (and only
that build's log) is written to the build's directory.
This requires a new version of ttystatus that supports multiline
output.
Diffstat (limited to 'ick')
-rwxr-xr-x | ick | 41 |
1 files changed, 31 insertions, 10 deletions
@@ -23,6 +23,7 @@ import StringIO import subprocess import cliapp +import ttystatus import yaml import icklib @@ -46,9 +47,9 @@ class Ick(cliapp.Application): def process_args(self, args): filename = self.parse_command_line_args(args) ick = self.read_ick_file(filename) - self.logger = icklib.Logger() - self.logger.add_output_file(self.output, self.settings['quiet']) + self.progress = self.create_ttystatus() self.build_projects(ick) + self.progress.finish() def parse_command_line_args(self, args): if len(args) != 1: @@ -59,20 +60,40 @@ class Ick(cliapp.Application): with open(filename) as f: return yaml.safe_load(f) + def create_ttystatus(self): + ts = ttystatus.TerminalStatus(period=0) + + if not self.settings['quiet']: + ts.format( + '%ElapsedTime() ' + 'Project %Index(project,projects) %String(project_name)\n' + 'Pipeline: %String(pipeline)\n' + 'Step: %String(step)\n' + 'Target: %String(target)\n' + 'Command: %String(command)\n' + 'Output: %String(line0)\n' + ' %String(line1)\n' + ' %String(line2)\n' + ' %String(line3)\n' + ' %String(line4)\n' + ' %String(line5)\n' + ' %String(line6)\n' + ' %String(line7)' + ) + ts.max_output_lines = 8 + return ts + def build_projects(self, ick): statedir = icklib.create_statedir_from_ick(ick) targets = icklib.create_targets_from_ick(ick, self.settings['target']) projects = icklib.create_projects_from_ick( ick, self.settings['project']) + self.progress['projects'] = projects for project in projects: - log_catcher = StringIO.StringIO() - self.logger.add_output_file(log_catcher, False) - self.logger.important( - 'Building project {project_name}', - project_name=project.name) - with self.logger: - project.set_logger(self.logger) - project.build(statedir, targets, log_catcher) + self.progress['project'] = project + self.progress['project_name'] = project.name + project.set_progress(self.progress) + project.build(statedir, targets) if __name__ == '__main__': |