Include error with ntfy failure messages
Although it is undocumented, *ntfy* accepts a `Message` header along with a file upload, which sets the message content of the notification when a file is attached. Since HTTP headers cannot contain multiple lines, the newline character has to be escaped. The *ntfy* server performs unescaping automatically.master
parent
58f417aea9
commit
55d5f6bd1a
17
xactfetch.py
17
xactfetch.py
|
@ -47,20 +47,22 @@ def ntfy(
|
||||||
if tags:
|
if tags:
|
||||||
headers['Tags'] = tags
|
headers['Tags'] = tags
|
||||||
url = f'{NTFY_URL}/{topic}'
|
url = f'{NTFY_URL}/{topic}'
|
||||||
if message:
|
if attach:
|
||||||
r = requests.post(
|
|
||||||
url,
|
|
||||||
headers=headers,
|
|
||||||
data=message,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if filename:
|
if filename:
|
||||||
headers['Filename'] = filename
|
headers['Filename'] = filename
|
||||||
|
if message:
|
||||||
|
headers['Message'] = message.replace('\n', '\\n')
|
||||||
r = requests.put(
|
r = requests.put(
|
||||||
url,
|
url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=attach,
|
data=attach,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
r = requests.post(
|
||||||
|
url,
|
||||||
|
headers=headers,
|
||||||
|
data=message,
|
||||||
|
)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,6 +271,7 @@ class ntfyerror:
|
||||||
if ss := self.page.screenshot():
|
if ss := self.page.screenshot():
|
||||||
save_screenshot(ss)
|
save_screenshot(ss)
|
||||||
ntfy(
|
ntfy(
|
||||||
|
message=str(exc_value),
|
||||||
title=f'xactfetch failed for {self.bank}',
|
title=f'xactfetch failed for {self.bank}',
|
||||||
tags='warning',
|
tags='warning',
|
||||||
attach=ss,
|
attach=ss,
|
||||||
|
|
Loading…
Reference in New Issue