# HG changeset patch # User Tero Marttila # Date 1357327599 -7200 # Node ID caed0ed82709d588a877f595e622f464bad4c283 # Parent 64885a7c6e85b60b49c58ceb996d982796af84b4 pvl.syslog.tail: re-implement seek=True diff -r 64885a7c6e85 -r caed0ed82709 pvl/syslog/tail.py --- a/pvl/syslog/tail.py Fri Jan 04 21:15:42 2013 +0200 +++ b/pvl/syslog/tail.py Fri Jan 04 21:26:39 2013 +0200 @@ -15,8 +15,11 @@ Works with python file objects that buffer readlines() when using e.g. `tail -f ... | python -u ...`. """ - def __init__ (self, file) : + def __init__ (self, file, skip=None) : self.file = file + + if skip : + self.skip() def readline (self) : """ @@ -65,9 +68,16 @@ Follow a file on the filesystem, reading lines until EOF, and re-opening if replaced. """ - def __init__ (self, path) : + def __init__ (self, path, **opts) : + log.debug("%s", path) + self.path = path - self.reopen() + self._stat = self.stat() + + file = self.open() + + # may call skip -> readlines -> changed() -> _stat + Tail.__init__(self, file, **opts) def stat (self) : """