webhook2lambda2sqs.utils module


Given an object, return a pretty-printed JSON representation of it.

Parameters:obj (object) – input object
Returns:pretty-printed JSON representation
Return type:str

Read a JSON file from fpath; raise an exception if it doesn’t exist.

Parameters:fpath (str) – path to file to read
Returns:deserialized JSON
Return type:dict
webhook2lambda2sqs.utils.run_cmd(args, stream=False, shell=True)[source]

Execute a command via subprocess.Popen; return its output (string, combined STDOUT and STDERR) and exit code (int). If stream is True, also stream the output to STDOUT in realtime.

  • args – the command to run and arguments, as a list or string
  • stream (bool) – whether or not to stream combined OUT and ERR in realtime
  • shell (bool) – whether or not to execute the command through the shell

2-tuple of (combined output (str), return code (int))

Return type: