pvl.syslog.tail: re-implement seek=True
authorTero Marttila <terom@fixme.fi>
Fri, 04 Jan 2013 21:26:39 +0200
changeset 59 caed0ed82709
parent 58 64885a7c6e85
child 60 9326ed989645
pvl.syslog.tail: re-implement seek=True
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) :
         """