#!/usr/bin/env python2.3 from webloglib import log_fields, TOP, ROW, END, COLOR import webloglib as wll from urllib import unquote_plus as uqp import os, time LOG = open('../access-log') RECS = [] PAGE = 'www/refresher.html' while 1: page = open(PAGE+'.tmp','w') RECS.extend(LOG.readlines()) RECS = RECS[-35:] print >> page, TOP odd = 0 for rec in RECS: hit = [field.strip('"') for field in log_fields(rec)] if hit[wll.status]=='200' and hit[wll.referrer]!='-': resource = hit[wll.request].split()[1] referrer = uqp(hit[wll.referrer]).replace('&',' &') print >> page, ROW % (COLOR[odd], referrer, resource) odd = not odd print >> page, END page.close() os.rename(PAGE+'.tmp',PAGE) time.sleep(5)