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   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Steve McClure                                     Racemi
email: [EMAIL PROTECTED]                        380 Interstate North Pkwy, SE
voice: 404-892-5850                               Suite 250
fax: 404-892-7215                                 Atlanta, GA 30339
                                                  http://www.racemi.com

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to