
Untitled
By: a guest on
Jul 11th, 2012 | syntax:
None | size: 1.18 KB | hits: 14 | expires: Never
import pynotify
import time
import os
import sys
pynotify.init("test")
def pushNotification (title, body, icon):
3 lines: n = pynotify.Notification (title, body, icon) ---------------------------------------------
def makeMessage (i):
9 lines: old_message = os.popen(i).read().strip() --------------------------------------------------
initial_input_list = os.popen("ls /home/daniel/log | grep -v \# | grep -v \& | grep -v server | grep -v core\.wee").readlines()
buffer_list = []
for s in initial_input_list:
buffer_list.append(s.strip())
oldnotifications = {}
while 1:
try:
for b in buffer_list:
try:
if oldnotifications[b] != str(os.stat("/home/daniel/log/" + b)):
i="tail -n1 /home/daniel/log/" + b
title,message = makeMessage(i)
pushNotification(title, message, "notification-message-im")
oldnotifications[b] = str(os.stat("/home/daniel/log/" + b))
except KeyError:
oldnotifications[b] = str(os.stat("/home/daniel/log/" + b))
time.sleep(.1)
except KeyboardInterrupt:
sys.exit(0)