Skip to content

Commit

Permalink
Handle THOLD alerts with no image/jpg or otherwise missing attachment
Browse files Browse the repository at this point in the history
* Handle multipart message with no image/jpg subpart
* Remove DEBUG print statements from get_image
  • Loading branch information
jamesboswell authored Jul 7, 2017
1 parent dd96ca8 commit b9f8773
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions thold-slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ def get_image(message):
# get the FIRST image JPEG version only
image_parts = [part for part in
typed_subpart_iterator(message, 'image', 'jpg')]
image_part = image_parts[0]
image_part = "" if len(image_parts) is 0 else image_parts[0]
return return_image(image_part)

else:
attachment = message.get_payload()[1]
payload = message.get_payload()
attachment = "" if len(payload) is 0 else payload[1]
return return_image(attachment)


Expand Down

0 comments on commit b9f8773

Please sign in to comment.