Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
Force file extension to lower case for type check
modified logging messages
  • Loading branch information
FlyingDiver committed Apr 15, 2019
1 parent 3c0d9c2 commit f55df01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Pushover.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>1.5.0</string>
<string>1.5.1</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
8 changes: 4 additions & 4 deletions Pushover.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ def send(self, pluginAction):

if self.present(pluginAction.props.get('msgAttachment')):
attachFile = self.prepareTextValue(pluginAction.props['msgAttachment'])
extension = os.path.splitext(attachFile)[1]
extension = os.path.splitext(attachFile.lower())[1]

if os.path.isfile(attachFile) and (extension == '.jpg' or extension == '.jpeg' or extension == '.gif'):
if os.path.isfile(attachFile) and (extension in ['.jpg', '.jpeg', '.gif']):
if os.path.getsize(attachFile) <= 2621440:
attachment = {
"attachment": (attachFile, open(attachFile, "rb"), "image/jpeg")
}
else:
self.logger.warn(u"Warning: attached file size was too large, attachment was skipped")
else:
self.logger.warn(u"Warning: file does not exist, or is not a jpeg file, attachment was skipped")
self.logger.warn(u"Warning: file does not exist, or is not an image file, attachment was skipped")

if self.present(pluginAction.props.get('msgPriority')):
params['priority'] = pluginAction.props['msgPriority']
Expand All @@ -116,7 +116,7 @@ def send(self, pluginAction):
self.debugLog(u"Result: %s" % r.text)

if r.status_code == 200:
self.logger.info(u"Pushover announcement was sent sucessfully, title: " + msgTitle + ", body: " + msgBody)
self.logger.info(u"Pushover notification was sent sucessfully, title: " + msgTitle + ", body: " + msgBody)
else:
self.logger.error(u"Result: %s" % r.text)

Expand Down

0 comments on commit f55df01

Please sign in to comment.