From de66501367c1ba4289be21e3a681776f7506d89d Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 22 Apr 2018 15:41:06 +0300 Subject: Add: icktool show-latet-log --- icktool | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'icktool') diff --git a/icktool b/icktool index 3cd5b4f..9230dd4 100755 --- a/icktool +++ b/icktool @@ -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() -- cgit v1.2.1