I'm running some terminal commands from within Python using the subprocess.check_output() call. This works all fine when it returns correct results. When interacting with the bitcoin daemon I can get several responses however. For example, the raw output (as seen on a normal bash command line) can be:
: Cannot obtain a lock on data directory /home/kramer65/.bitcoin. Bitcoin is probably already running.
or
error: couldn't connect to server
Both these responses give an error code 1 however. I tried printing out the following attributes of the subprocess.CalledProcessError as e, which in both cases results in the same outputs (except for the cmd attribute of course:
print e.args, e.cmd, e.message, e.output, e.returncode
# () 'BTC' 1
# () 'BTC getinfo' 1
I guess the only thing that distincts the two errors, is the raw string that is outputted on the command line which I listed above. So my question is: how can I get the raw string that is shown on the command line from within Python?