Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jq_cmd_array.append(filter_)
self.logger.info("Command to Run: {}".format(jq_cmd_array))
process = subprocess.Popen(jq_cmd_array, stdout=PIPE, stderr=PIPE, stdin=PIPE)
std_out, std_err = process.communicate(input=json.dumps(json_in).encode(), timeout=timeout)
return_code = process.returncode
self.logger.info("Return Code: {}".format(return_code))
if return_code > 0:
self.logger.info("JQ Standard Output: {}".format(std_out.decode()))
self.logger.info("JQ Standard Error: {}".format(std_err.decode()))
raise Exception("JQ failed with return code: {}".format(return_code))
output_string = std_out.decode('utf-8').strip()
return {Output.JSON_OUT: output_string}