I am not entirely sure how jq works here with subprocess so there is a misunderstanding but I am trying to get the extact format from using jq on the command line ( jq > file.json
) with subprocess. This is what I have but the following produces an empty file.
os.makedirs(os.path.dirname(filePath))
open(filePath, 'a').close()
call(["bw", "list", "--session", session_key, \
"collections", "|", "jq", ".", ">", filePath])
I have also tried
with open(filePath, "w+") as output:
call(["bw", "list", "--session", session_key, \
"collections", "|", "jq", "."], stdout=output)
But this produces a string instead of the actual formatting of jq. Is there a way for me to obtain the stdout jq on the commandline into a file using python?