diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-04-20 18:09:20 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-04-20 18:09:20 +0300 |
commit | 659bc5b577097a451b162c9c552e803e3a824e39 (patch) | |
tree | 6ed9db250726c97fe707cdd58bf39523a8f3ce12 /icktool | |
parent | a5b936709740ab5b4a101155d6b99b423dff440b (diff) | |
download | ick2-659bc5b577097a451b162c9c552e803e3a824e39.tar.gz |
Change: adjust to _new_token change, add status and trigger commands
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 56 |
1 files changed, 37 insertions, 19 deletions
@@ -109,21 +109,47 @@ class Icktool(cliapp.Application): self.output.write('{}\n'.format(scope)) def cmd_token(self, args): - token = self._new_token() + api = self._new_api() + token = self._new_token(api) self.output.write('{}\n'.format(token)) def cmd_version(self, args): - token = self._new_token() api = self._new_api() + token = self._new_token(api) api.set_token(token) version = api.get_version() self._prettyson(version) + def cmd_status(self, args): + api = self._new_api() + token = self._new_token(api) + api.set_token(token) + projects = api.show('/projects') + builds = api.show('/builds') + for project in projects['projects']: + project_name = project['project'] + status = api.show('/projects/{}/status'.format(project_name)) + build = self._latest_build(project_name, builds) + self._prettyson(builds) + if build: + actions = build['actions'] + current = build['current_action'] + log = build['log'] + print(project_name, status['status'], log, actions[current]) + else: + print(project_name, status['status'], 'no builds') + + def _latest_build(self, project_name, builds): + builds = [b for b in builds['builds'] if b['project'] == project_name] + if builds: + return builds[-1] + return None + def cmd_make_it_so(self, argv): obj = self._read_object() - token = self._new_token() api = self._new_api() + token = self._new_token(api) api.set_token(token) self._create_resources(api, '/projects', obj.get('projects', [])) @@ -136,9 +162,16 @@ class Icktool(cliapp.Application): for obj in objs: api.create(path, obj) + def cmd_trigger(self, args): + project = args[0] + api = self._new_api() + token = self._new_token(api) + api.set_token(token) + self._prettyson(api.trigger(project)) + def cmd_show(self, args): - token = self._new_token() api = self._new_api() + token = self._new_token(api) api.set_token(token) if not args: args = [ @@ -184,19 +217,4 @@ class Icktool(cliapp.Application): self.output.write('\n') -class Command: - - def __init__(self, api): - self._api = api - - def execute(self): - raise NotImplementedError() - - -class VersionCommand(Command): - - def execute(self): - self._api.get_version() - - Icktool(version=ick2.__version__).run() |