[pygtk] way to tail a log file to a veiwer
Steve McClure
sMcClure at racemi.com
Thu Feb 1 03:59:17 WST 2007
On Wed, 2007-01-31 at 12:38 -0600, shawn bright wrote:
> lo there,
>
> i am looking for an easy way to tail a log file and pipe its output to
> a text view.
>
> any ideas ?
>
> sk
I used the gnome.vfs.monitor_add() method:
fname = self.getServiceLogFullPath(service)
fi = gnome.vfs.get_file_info(fname)
self.position[service] = fi.size - 1
source = gnome.vfs.monitor_add(fname, gnome.vfs.MONITOR_EVENT_CHANGED, self.addData, service)
then my handler:
def addData(self, monitorPath, infoPath, eventType, service):
fname = self.getServiceLogFullPath(service)
source = open(fname, 'r')
pos = self.position[service]
source.seek(pos, 0) # put the pointer at the right place
data = source.readline()
iter = self.buffer.get_end_iter()
...
There is probably a better way to handle the file position, etc, than
the way I did it.
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
Steve McClure Racemi
email: smcclure at racemi.com 380 Interstate North Pkwy, SE
voice: 404-892-5850 Suite 250
fax: 404-892-7215 Atlanta, GA 30339
http://www.racemi.com
More information about the pygtk
mailing list