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

View File

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