5 ms·
Having watched people hack together utterly bizarre bash scripts with awk and grep to handle json responses I'd very much agree here. And before someone raises
by ShorsHammer 7y ago
Having watched people hack together utterly bizarre bash scripts with awk and grep to handle json responses I'd very much agree here.
And before someone raises jq, what % of servers already have python installed vs jq?
- heavyset_go 7y ago> And before someone raises jq, what % of servers already have python installed vs jq? How many of those servers have something like requests installed out of the box vs needing to fetch it via a package manager or PyPI? jq is available in Ubuntu's universe repository along with requests.
- ShorsHammer 7y agoit's python, requests is one of it's many libraries for the purpose, would actually be quite concerned hiring someone who doesn't know the multiple stdlib solutions for this and still claims ability in python. import json import urllib.request tough hey
- heavyset_go 7y agoI'd be as concerned with someone not opting to use what the documentation recommends[1] in lieu of the stdlib, as I would someone who puts together an awkward Bash script to parse JSON instead of just installing the 50kb package for jq. > The Requests package is recommended for a higher-level HTTP client interface. [1] https://docs.python.org/3/library/urllib.request.html https://docs.python.org/3/library/urllib.request.html
- ShorsHammer 7y agoIt's a lot easier to hire people than fire them friend. The documentation recommends nothing of the sort, it's a direction for consumers. We all live in varied and different worlds, how many varied server environments have you been responsible for all at once? Is it really beyond your amazing programming skills to use the tools at hand in every circumstance? Perhaps it's a chance to demonstrate yet another 3rd party tool which fixes non-existent problems. It's a few bytes difference in your script that is using requests over the numerous and plentiful stdlib options there.
- vaingloriole 7y agoWould never use python in lieu of curl/jq for json handling unless I am writing something more complicated than a shell script. catch 22.
- ShorsHammer 7y agoIf it gets the job done good on you. Each to their own. Simply saying what I would look for. Have any examples of your apt install jq script? How would you install jq on a few hundred machines also? I'd be happy to share an example of an out of the box python script that does the same job and works virtually everywhere.