dgzlopes / tcp-latency

Module and command-line tool to measure latency using TCP.
https://pypi.org/project/tcp-latency/
MIT License
58 stars 15 forks source link

Add support for machine readable output #3

Open dgzlopes opened 4 years ago

dgzlopes commented 4 years ago

Add a flag, where you can specify the desired format.

e.g --output json or --output xml

Moras-del commented 4 years ago

I can solve that.

dgzlopes commented 4 years ago

Nice @Moras-del! If you need help, feel free to ping me.

Moras-del commented 4 years ago

I would like to be sure. Do You want to support xml/json format only when program is used as module? E.g def measure_latency( host, port = 443, timeout = 5, runs = 1, wait = 1, human_output = False, format='json' ) -> list: as I understand the content returned from the CLI should also be returned from the function call (when human_output=False, format='json/xml/None') in specified format, like: 'host': 'www.google.com', 'protocol': 'tcp', 'seq': '1', 'port': '443', 'timeout': '5', 'time': '200ms' Am I correct?

dgzlopes commented 4 years ago

Yep. So we can use tools like jq to work with the data.

Human-output should be the default, but I think having other options (e.g JSON, XML, CSV, whatever) might be useful.

Moras-del commented 4 years ago

Ok but measure_latency() should also return list of json objects instead of latency points if specified? Or format should be used ONLY for working with CLI?

dgzlopes commented 4 years ago

In my opinion: CLI only :stuck_out_tongue:

I don't want to mess with how people invoke measure_latency(). And I don't think it's useful to get a list of JSON objects!

Moras-del commented 4 years ago

okay :)