summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-22 15:41:06 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-22 15:41:06 +0300
commitde66501367c1ba4289be21e3a681776f7506d89d (patch)
tree0233cb69e46585196fc4e7321990aea9338c052b /icktool
parent5e074ea7b459dd8aa6a7a9b0a2ce6abc1a53ec84 (diff)
downloadick2-de66501367c1ba4289be21e3a681776f7506d89d.tar.gz
Add: icktool show-latet-log
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool28
1 files changed, 28 insertions, 0 deletions
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()