diff options
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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() |