updated requests/files reference

This commit is contained in:
Chris Caron 2019-11-21 21:52:20 -05:00
parent 1a83623e3c
commit f4a7df0520
2 changed files with 6 additions and 5 deletions

View File

@ -317,7 +317,7 @@ class NotifyDiscord(NotifyBase):
# Open our attachment path if required:
if attach:
files = (attach.name, open(attach.path, 'rb'))
files = {'file': (attach.name, open(attach.path, 'rb'))}
r = requests.post(
notify_url,
@ -347,7 +347,8 @@ class NotifyDiscord(NotifyBase):
return False
else:
self.logger.info('Sent Discord notification.')
self.logger.info('Sent Discord {}.'.format(
'attachment' if attach else 'notification'))
except requests.RequestException as e:
self.logger.warning(
@ -367,7 +368,7 @@ class NotifyDiscord(NotifyBase):
# Close our file (if it's open) stored in the second element
# of our files tuple (index 1)
if files:
files[1].close()
files['file'][1].close()
return True

View File

@ -487,7 +487,7 @@ class NotifySlack(NotifyBase):
try:
# Open our attachment path if required:
if attach:
files = (attach.name, open(attach.path, 'rb'))
files = {'file': (attach.name, open(attach.path, 'rb'))}
r = requests.post(
url,
@ -622,7 +622,7 @@ class NotifySlack(NotifyBase):
# Close our file (if it's open) stored in the second element
# of our files tuple (index 1)
if files:
files[1].close()
files['file'][1].close()
# Return the response for processing
return response