def main(): (options, message) = ClientParser().parse_args() logging.basicConfig(level=options.verbose) growl = GrowlNotifier( applicationName=options.app, notifications=[options.name], defaultNotifications=[options.name], hostname=options.host, password=options.password, port=options.port, ) result = growl.register() if result is not True: exit(result) # 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'): logging.info('Loading image %s', options.icon) f = open(options.icon) options.icon = f.read() f.close() result = growl.notify( noteType=options.name, title=options.title, description=message, icon=options.icon, sticky=options.sticky, priority=options.priority, callback=options.callback, ) if result is not True: exit(result)
class GNTPTestCase(unittest.TestCase): notification = { 'noteType': 'Testing', 'title': 'Unittest Title', 'description': 'Unittest Description', } def setUp(self): self.growl = GrowlNotifier('GNTP unittest', ['Testing']) self.growl.register() def _notify(self, **kargs): for k in self.notification: if not k in kargs: kargs[k] = self.notification[k] return self.growl.notify(**kargs)
class GNTPTestCase(unittest.TestCase): application = 'GNTP unittest' notification_name = 'Testing' notification = { 'noteType': notification_name, 'title': 'Unittest Title', 'description': 'Unittest Description', } def setUp(self): self.growl = GrowlNotifier(self.application, [self.notification_name]) self.growl.register() def _notify(self, **kargs): for k in self.notification: if not k in kargs: kargs[k] = self.notification[k] return self.growl.notify(**kargs) def assertIsTrue(self, result): """Python 2.5 safe way to assert that the result is true""" return self.assertEqual(result, True)
def post(self, request): growl = GrowlNotifier(notifications=['Test']) growl.register() growl.notify('Test', 'Test', 'Test') return HttpResponse('result')