diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-01-26 17:13:12 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-01-26 17:13:12 +0200 |
commit | 637b59b5709932cbb35cf59600009559c089827b (patch) | |
tree | 7335fca36ab4e3bb0424830a38f125ef64de7b9d | |
parent | bf9309765960ea049890bd8ce9fe36e8da1dc827 (diff) | |
download | ick2-637b59b5709932cbb35cf59600009559c089827b.tar.gz |
Change: sort output of icktool
-rwxr-xr-x | check | 2 | ||||
-rwxr-xr-x | icktool | 32 | ||||
-rw-r--r-- | pylint.conf | 1 |
3 files changed, 19 insertions, 16 deletions
@@ -74,7 +74,7 @@ then ./is-agpl3+ $sources fi - python_sources="ick_controller.py worker_manager ick2" + python_sources="ick_controller.py worker_manager ick2 icktool" title pycodestyle pycodestyle ick2 $python_sources @@ -40,9 +40,9 @@ def scopes(base): return [x.format(base) for x in patterns] -def scopes_for_types(types): +def scopes_for_types(typelist): result = [] - for type_name in types: + for type_name in typelist: result.extend(scopes(type_name)) return result @@ -124,9 +124,11 @@ class Icktool(cliapp.Application): def cmd_status(self, args): rows = [] projects = self._get_projects() + project_objs = sorted( + projects['projects'], key=lambda p: p.get('project')) builds = self._get_builds()['builds'] - for project in projects['projects']: - pipelines = project['pipelines'] + for project in project_objs: + pipelines = sorted(project['pipelines']) for pipeline in pipelines: build = self._get_latest_build( project['project'], pipeline, builds) @@ -152,17 +154,17 @@ class Icktool(cliapp.Application): def _get_projects(self): rc = self._new_rc('/projects', 'project') - return rc.list() + projects = rc.list() + return projects def _get_builds(self): rc = self._new_rc('/builds', 'build') return rc.list() - def _get_latest_build(self, project_name, pipeline_name, builds): + def _get_latest_build(self, project, pipeline, builds): latest = None for build in builds: - if (build['project'] == project_name and - build['pipeline'] == pipeline_name): + if (build['project'], build['pipeline']) == (project, pipeline): latest = build return latest @@ -339,14 +341,14 @@ class Icktool(cliapp.Application): sys.exit(text) def _new_token(self): - scopes = self.settings['scope'] + wanted_scopes = self.settings['scope'] cmd = self.settings['token-private-key-cmd'] if not cmd: raise cliapp.AppException('no --token-private-cmd specified') gen = TokenGenerator() gen.set_cmd(cmd) - gen.set_scopes(scopes) + gen.set_scopes(wanted_scopes) token = gen.new_token() self.settings['token'] = token return token @@ -566,8 +568,8 @@ class TokenGenerator: def set_cmd(self, cmd): self._cmd = cmd - def set_scopes(self, scopes): - self._scopes = scopes + def set_scopes(self, wanted_scopes): + self._scopes = wanted_scopes def new_token(self): assert self._cmd is not None @@ -581,15 +583,15 @@ class TokenGenerator: privkey = cliapp.runcmd(['sh', '-c', self._cmd]) key = Crypto.PublicKey.RSA.importKey(privkey) - scopes = ' '.join(self._scopes) + wanted_scopes = ' '.join(self._scopes) now = time.time() claims = { 'iss': iss, 'sub': 'subject-uuid', 'aud': aud, - 'exp': now + 86400, # FIXME: This is silly long - 'scope': scopes, + 'exp': now + 86400, + 'scope': wanted_scopes, } token = apifw.create_token(claims, key) diff --git a/pylint.conf b/pylint.conf index 4c07cc8..a88798e 100644 --- a/pylint.conf +++ b/pylint.conf @@ -9,6 +9,7 @@ disable= no-self-use, not-callable, too-few-public-methods, + too-many-public-methods, unused-argument, unused-variable |