You could have something along the lines of -

import os.path
import time

curTime = os.path.getmtime('log.txt') #Or whatever it's called.

while 1: #or some other loop
   time.sleep(10) #Check logfile every ten seconds.
   if  os.path.getmtime('log.txt') != curTime:
          curTime = os.path.getmtime('log.txt')
          x=file('log.txt','r')...


So basically, just check the modification time. If  the modification
time has changed, then the file's been updated.

It's one way to do it. : )

Liam Clarke

On Thu, 09 Dec 2004 17:28:56 +0000, Philip Kilner <[EMAIL PROTECTED]> wrote:
> Hi List,
> 
> I have a closed-source application which creates log files. I'd like to
> capture this logfile data as it is crated, and do clever things with it!
> 
> Is this possible? I guess it must be, because there are "tail" type
> utilities for Windows...
> 
> Is it possible in Python? I'd be grateful for any pointers!
> 
> BTW, it doesn't matter either way whether I can somehow pipe the log
> output to my program /without/ the file actually being created, or if I
> can capture it /as/ it is created - I just need to get my mitts on the
> data as it is generated...it would be better if I had the file as well,
> but it is not essential...
> 
> Thanks in Anticipation!
> 
> --
> 
> Regards,
> 
> PhilK
> 
> Email: [EMAIL PROTECTED] / Voicemail & Facsimile: 07092 070518
> 
> "Work as if you lived in the early days of a better nation." - Alasdair Gray
> _______________________________________________
> Tutor maillist  -  [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to