diff --git a/lib/gntp/LICENSE b/lib/gntp/LICENSE deleted file mode 100644 index c274a5a2..00000000 --- a/lib/gntp/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2013 Paul Traylor - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/gntp/cli.py b/lib/gntp/cli.py index bc083062..97e74af7 100644 --- a/lib/gntp/cli.py +++ b/lib/gntp/cli.py @@ -118,9 +118,9 @@ def main(): # This would likely be better placed within the growl notifier # class but until I make _checkIcon smarter this is "easier" - if options.icon is not None and not options.icon.startswith('http'): + if options.icon and growl._checkIcon(options.icon) is False: logging.info('Loading image %s', options.icon) - f = open(options.icon) + f = open(options.icon, 'rb') options.icon = f.read() f.close() diff --git a/lib/gntp/core.py b/lib/gntp/core.py index 957b5270..6492c6f3 100644 --- a/lib/gntp/core.py +++ b/lib/gntp/core.py @@ -74,8 +74,15 @@ class _GNTPBase(object): self.headers = {} self.resources = {} - def __str__(self): - return self.encode() + # For Python2 we can just return the bytes as is without worry + # but on Python3 we want to make sure we return the packet as + # a unicode string so that things like logging won't get confused + if gntp.shim.PY2: + def __str__(self): + return self.encode() + else: + def __str__(self): + return gntp.shim.u(self.encode()) def _parse_info(self, data): """Parse the first line of a GNTP message to get security and other info values diff --git a/lib/gntp/notifier.py b/lib/gntp/notifier.py index 1719ecdf..fb923568 100644 --- a/lib/gntp/notifier.py +++ b/lib/gntp/notifier.py @@ -69,7 +69,8 @@ class GrowlNotifier(object): then we return False ''' logger.info('Checking icon') - return gntp.shim.u(data).startswith('http') + + return gntp.shim.u(data)[:4] in ['http', 'file'] def register(self): """Send GNTP Registration diff --git a/lib/gntp/shim.py b/lib/gntp/shim.py index 3a387828..2d6b6d73 100644 --- a/lib/gntp/shim.py +++ b/lib/gntp/shim.py @@ -10,6 +10,7 @@ https://pypi.python.org/pypi/six import sys +PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY3: diff --git a/lib/gntp/version.py b/lib/gntp/version.py index 2166aaca..4268a538 100644 --- a/lib/gntp/version.py +++ b/lib/gntp/version.py @@ -1,4 +1,4 @@ # Copyright: 2013 Paul Traylor # These sources are released under the terms of the MIT license: see LICENSE -__version__ = '1.0.2' +__version__ = '1.0.3'