diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-04-22 15:41:06 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-04-22 15:41:06 +0300 |
commit | de66501367c1ba4289be21e3a681776f7506d89d (patch) | |
tree | 0233cb69e46585196fc4e7321990aea9338c052b | |
parent | 5e074ea7b459dd8aa6a7a9b0a2ce6abc1a53ec84 (diff) | |
download | ick2-de66501367c1ba4289be21e3a681776f7506d89d.tar.gz |
Add: icktool show-latet-log
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | icktool | 28 |
2 files changed, 30 insertions, 0 deletions
@@ -24,6 +24,8 @@ Version 0.45+git, not yet released `systree_name` parameter, if no `systree_name` field is given, or its value is `auto`. +* New command: `icktool show-latest-log PROJECT`. + Version 0.45, released 2018-04-21 ---------------------------------- @@ -142,6 +142,10 @@ class Icktool(cliapp.Application): cmd = self._command(ShowLogCommand) cmd.execute(args) + def cmd_show_latest_log(self, args): + cmd = self._command(ShowLatestLogCommand) + cmd.execute(args) + def _command(self, klass): api = self._new_api() token = self._new_token(api) @@ -429,4 +433,28 @@ class ShowLogCommand(Command): self.output.write('\n') +class ShowLatestLogCommand(Command): + + def execute(self, args): + builds = self.api.show('/builds') + if builds: + builds = builds['builds'] + + for project in args: + latest = self._get_latest_build(builds, project) + if latest: + log_id = latest['log'] + log = self.api.show_blob(log_id) + log = log.decode('UTF-8') + self.output.write(log) + if not log.endswith('\n'): + self.output.write('\n') + + def _get_latest_build(self, builds, project): + builds = [b for b in builds if b['project'] == project] + if builds: + return builds[-1] + return None + + Icktool(version=ick2.__version__).run() |