
I am stuk CHECK my Code - access.txt (0/1)
#This is my code:
#And what it is supposed 2 do:
#it is supposed 2 first put a window on screen at this moment a fairly
#simple thing. But it does not the program goes straight into
#executing the def read(file) function. And that's not what i want!!!
#It should be as followed start python <program> see code put window
#on screen wait until start button is pressed then excute def
#read(file) funtion and wil this is running you should be able 2 quit
#at any time you decide by pressing the quit button!!!!
#By the way the programm's main function is 2 read in the access file
#and should try 2 read past EOF so you get a realtime vieuw af wat is
#happening on your http server!!
import re
import string
import time
import os
import sys
from Tkinter import *
file = 'access'
#realtimefile = open (file,'r')
path = ''
path1 = '/internet/193.24.221.01/'
just_a_string = "webber.inet.nl - - [23/Sep/1998:09:12:42 +0200] GET
/~nico/test.htm"
class Windows(Frame):
def read(self,readfile):
realtimefile = open (readfile,'r')
while(1):
just_a_string=realtimefile.readline()
if (len(just_a_string)==0):
time.sleep(1)
#break;
#if (raw_input()):
# sys.exit(0)
if (re.search(".htm",just_a_string)):
splitted_string =
re.split('[\s]',just_a_string)
date = splitted_string[3]
server = splitted_string[0]
url = splitted_string[6]
#print splitted_string
self.date1.insert(END, date[1:]+"\n")
self.url1.insert(END, url+"\n")
self.server1.insert(END, server+"\n")
print "%s %s %s" %
(date[1:],url,server)
def CreateWidgets(self):
self.frame = Frame(self,width = 500,height = 300,
background = 'grey')
self.frame.pack(side=TOP)
self.date1 = Text(self,width = 18, height = 5)
self.date1.place(relx=0.05,rely=0.6)
self.url1 = Text(self,width = 25, height = 5)
self.url1.place(relx=0.30,rely=0.6)
self.server1 = Text(self,width = 25, height = 5)
self.server1.place(relx=0.65,rely=0.6)
self.QUIT = Button(self, text='QUIT',
foreground='red',
command=self.quit)
self.QUIT.place(relx=0.90, rely=0.9)
self.start = Button(self, text='Start',
foreground='blue',
command=self.read(file))
self.start.place(relx=0.05, rely=0.9)
message1 = ("[Reading %s LogFile RealTiMe at %s]") %
(file,path1)
self.label1 = Message(self, width="5i",
text=message1,background ='blue',foreground='white')
self.label1.place(relx=0.05,rely=0.05)
self.date1 = Message(self, width="5i",
text="Date",background ='blue',foreground='black')
self.date1.place(relx=0.05,rely=0.5)
self.url1 = Message(self, width="5i",
text="Url",background ='blue',foreground='black')
self.url1.place(relx=0.30,rely=0.5)
self.server1 = Message(self, width="5i",
text="Server",background ='blue',foreground='black')
self.server1.place(relx=0.65,rely=0.5)
def __init__(self,master=None):
Frame.__init__(self,master)
Pack.config(self)
self.CreateWidgets()
window = Windows()
window.mainloop()
#author ids Achterhof
#i will be releasing full version when int work to my satisfaction!!
#if you think it wil be usefull 2 you