def __init__(self, server=None): FooApp.__init__(self, server) self.data = FileStore('/tmp/apps/growl') self.sock = socket(AF_INET, SOCK_DGRAM) p = GrowlRegistrationPacket(application='foobox', password='') p.addNotification('Message', enabled=True) self.sock.sendto(p.payload(), (self.data['target'], GROWL_UDP_PORT))
def register_notifications(self, hosts): """Asks Growl clients to register Trac application. A bit suboptimal, but that's the only way to register without an explicit user registration""" grp = GrowlRegistrationPacket() for n in self.avail_sources: grp.addNotification(n, n in self.sources) gs = GrowlSender(self.env) gs.notify(hosts, grp)
def send_growl_notification(self): growl_ips = self.growl_ips reg = GrowlRegistrationPacket(password=self.password) reg.addNotification() notify = GrowlNotificationPacket(title=self.title, description=self.description, sticky=True, password=self.password) for ip in growl_ips: addr = (ip, GROWL_UDP_PORT) s = socket(AF_INET, SOCK_DGRAM) s.sendto(reg.payload(), addr) s.sendto(notify.payload(), addr)