I am stuk CHECK my Code - access.txt (0/1) 
Author Message
 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



Mon, 16 Apr 2001 03:00:00 GMT  
 I am stuk CHECK my Code - access.txt (0/1)

I> #This is my code:
I> #And what it is supposed 2 do:
I> #it is supposed 2 first put a window on screen at this moment a fairly

I> #simple thing. But it does not the program goes straight into
I> #executing the def read(file) function. And that's not what i want!!!

I>           self.start = Button(self, text='Start',
I> foreground='blue',
I>                              command=self.read(file))
Please post your code without linebreaks

                self.start = Button(self, text='Start', foreground='blue',
                                   command=lambda self=self:self.read(file))
                                           ^^^^^^^^^^^^^^^^^
What you dis is to use the RESULT of reading the file as a command for the
Button, rather than the code to read the file.

With regard to reading ``past'' EOF, I think you must reposition the file
or maybe even reopen it, after a sleep period.
--

URL: http://www.cs.uu.nl/~piet [PGP]



Tue, 17 Apr 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Generator yielding unwanted code - code.txt (1/1)

2. Generator yielding unwanted code - code.txt (0/1)

3. Checking AM or PM

4. Opening .txt files created by Labview with MS ACCESS

5. Please check my code (long code)

6. File Conversion: UNIX.txt to DOS.txt and trim trailing blanks

7. if file1.txt < file2.txt echo smaller

8. Urgent!!Oracle9i:using ODBC, I am noy able to link to my database tables using Access

9. I am getting timeouts trying to access parallel port with VISA

10. how do i code a txt file

11. code help making a .txt file

12. The (Hebrew) Geek Code - hebgeek.txt [1/1]

 

 
Powered by phpBB® Forum Software