diff options
-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() |