Closed mohabusama closed 8 years ago
__main__.py
to use python3 -m zmon_cli
(that's how all STUPS tools work)awk
) --- please use the --output
flag to suppress the "Action" output (this is automatically done with OutputFormat
)Added custom Output
to adjust unified output formatting and error/exception handling. This is done for most commands, and default format varies depending on the command.
I get an KeyError now:
$ python3 -m zmon_cli ent filter type local
EXCEPTION OCCURRED: 'team'
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/__main__.py", line 6, in <module>
main()
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/main.py", line 10, in main
cli()
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 27, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/cmds/entity.py", line 57, in filter_entities
act.echo(entities)
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/output.py", line 95, in echo
self.printer(out, self.output)
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/output.py", line 115, in render_entities
rows.sort(key=lambda r: (r['id'], r['type'], r['team']))
File "/home/hjacobs/workspace/zmon-cli/zmon_cli/output.py", line 115, in <lambda>
rows.sort(key=lambda r: (r['id'], r['type'], r['team']))
KeyError: 'team'
Removed team
from col output. I assumed all entities has team assigned.
@mohabusama you can actually introduce "last_modified" column instead (with nice "..ago" coloring by "print_table")
:+1:
👍
Note: some of the Zmon client method names are not consistent (update vs create vs add). It is somehow similar to the commands. I was not sure whether we should unify this in this iteration or wait for next upgrade, in order to avoid confusion for users (
zmon e push
vszmon e create
)