#!/usr/bin/python ''' A python scripts that listens on port 514 for UDP connections e.g. from US Robotics and displays the log via growl Requires Python 2.3 or higher and Growl Copyright 2007 Christian Fufezan ''' from Growl import * from socket import * from time import localtime,asctime host = '' port = 514 buf = 8192 address = (host,port) class GROWLNOTIFIER(GrowlNotifier): def __init__(self): self.applicationName = 'gSyslog' self.applicationIcon = Image.imageWithIconForApplication('/Applications/Utilities/Console.app') self.notifications = ['gSyslog msg','Connection allowed', 'Connection denied'] self.register() self.notify(self.notifications[0],'_gSyslog_init_','Starting listing\n'+str(asctime(localtime())),sticky=1) if __name__ == '__main__': UDPSocket = socket(AF_INET,SOCK_DGRAM) UDPSocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) UDPSocket.bind(address) print 'talking to Growl' gSyslog = GROWLNOTIFIER() print 'starting Listening ...' try: while 1: data,addr = UDPSocket.recvfrom(buf) no_idx = data[4:] gSyslog.notify(gSyslog.notifications[0],'_gSyslog_'+str(asctime(localtime())),no_idx+'\n') print no_idx except KeyboardInterrupt: # Close socket print '\nExiting ...' UDPSocket.close()