This repository has been archived by the owner on Jul 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
local.py
49 lines (42 loc) · 1.38 KB
/
local.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gntp
import Growl
GNTPParseError = gntp.GNTPParseError
GNTPOK = gntp.GNTPOK
GNTPError = gntp.GNTPError
parse_gntp = gntp.parse_gntp
class GNTPRegister(gntp.GNTPRegister):
def send(self):
print 'Sending Local Registration'
#Local growls only need a list of strings
notifications=[]
defaultNotifications = []
for notice in self.notifications:
notifications.append(notice['Notification-Name'])
if notice.get('Notification-Enabled',True):
defaultNotifications.append(notice['Notification-Name'])
growl = Growl.GrowlNotifier(
applicationName = self.headers['Application-Name'],
notifications = notifications,
defaultNotifications = defaultNotifications,
)
growl.register()
class GNTPNotice(gntp.GNTPNotice):
def send(self):
print 'Sending Local Notification'
growl = Growl.GrowlNotifier(
applicationName = self.headers['Application-Name'],
notifications = [self.headers['Notification-Name']]
)
noticeIcon = None
if self.headers.get('Notification-Icon',False):
resource = self.headers['Notification-Icon'].split('://')
#print resource
resource = self.resources.get(resource[1],False)
#print resource
if resource:
noticeIcon = resource['Data']
growl.notify(
noteType = self.headers['Notification-Name'],
title = self.headers['Notification-Title'],
description=self.headers['Notification-Text'],
)