Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. #intelparser.py
  2.  
  3. import os
  4.  
  5. def watch_log(logpath):
  6.    
  7.     lastLine = 0;
  8.     lastFileSize = 0;
  9.    
  10.     while (!quit):
  11.         fileStats = os.stat(logpath)
  12.        
  13.         if fileStats.st_size > lastFileSize:
  14.             f = open(logpath, 'r')
  15.             lines = f.readlines()
  16.             i = lastLine
  17.             while i < len(lines):
  18.                 line = lines[i]
  19.                 #some method to send the line to the db
  20.            
  21.             lastFileSize = fileStats.st_size
  22.             lastLine = len(lines) - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement