On Tue, 27 Jan 2015 11:19 -0800, Kathy Allen <
kal...@gmail.com> wrote:
> TASK: [debug msg={{my_msg}}] **************************************************
> Tuesday 27 January 2015 19:05:10 +0000 (0:00:00.000) 0:00:00.040 *******
> ok: [127.0.0.1] => {
> "msg": "A - i am a runon sentence\ni go on and on and on"
> }
I believe this is being processed by Jinja2, which is ignoring the
newline.
> TASK: [debug msg="B - i am a runon sentence \n i go on and on and on"] ********
> Tuesday 27 January 2015 19:05:10 +0000 (0:00:00.005) 0:00:00.045 *******
> ok: [127.0.0.1] => {
> "msg": "B - i am a runon sentence \\n i go on and on and on"
> }
Here debug is calling exit_json() which in turns calls json.dumps() [1],
which will escape the newline.
>>> json.dumps("one line\nanother line")
'"one line\\nanother line"'
You'll notice that in hipchat you don't see "\\n" but "\n". The function
send_msg() in the hipchat module is correctly calling urllib.urlencode()
to create the URL and then making the external call (no JSON involved
here). I believe this is a separate issue (i.e. hipchat not correctly
interpreting newlines).
[1] -
https://docs.python.org/2/library/json.html