#!/usr/bin/env python # GrowlWarn # nosmo@netsoc.tcd.ie # 11/06/07 import Growl, re progname = "LastGrowl" g = Growl.GrowlNotifier(applicationName=progname, notifications=["stuff"]) g.applicationIcon = None g.register() filename = '/Library/Logs/Console/502/console.log' log = open(filename) lines = log.readlines() numlin = len(lines) numlin = numlin - 1 growlapp = re.compile('.*GrowlHelperApp.*') mat = growlapp.match(lines[numlin]) words = re.split('[\s+ ]',lines[numlin]) growlapp = re.compile('GrowlHelperApp\[\d{3}\]') mat = growlapp.match(words[2]) while numlin: if mat: appname = re.compile('[\W\w]+:') if appname.match(words[7]): appname = words[7].split(':') appname = appname[0] wordsleft = len(words) - 1 appmsg = re.split('[()]', lines[numlin]) appmsg = appmsg[1] if appname == progname: continue else: print appname print appmsg g.notify(noteType="stuff", title=appname, description=appmsg, sticky=False) break numlin = numlin - 1 words = re.split('[\s+ ]',lines[numlin])