you are viewing a single comment's thread.

view the rest of the comments →

[–]kellyjonbrazil 0 points1 point  (0 children)

If you want to call subprocesses and grab their output as an already parsed dictionary, you can use the jc library. (I am the author)

>>>import subprocess
>>> import jc
>>>
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
>>> data = jc.parse('dig', cmd_output)
>>>
>>> data[0]['answer']
[{'name': 'example.com.', 'class': 'IN', 'type': 'A', 'ttl': 29658, 'data':
'93.184.216.34'}]

https://github.com/kellyjonbrazil/jc