Commit f7603876 authored by ale's avatar ale

renamed io.py to ioutil.py to avoid conflict with python stdlib

parent 7cd13400
def read_file(path):
with open(path, 'rb') as fd:
for line in fd:
try:
line = unicode(line, 'utf-8', 'replace')
except UnicodeDecodeError:
continue
yield line.rstrip('\n')
def read_fifo(fifo_path):
while True:
for line in read_file(fifo_path):
yield line
......@@ -2,7 +2,7 @@ import logging
import optparse
import sys
from lens2 import daemonize
from lens2 import io
from lens2 import ioutil
from lens2 import logstore
from lens2 import pattern
from lens2 import syslog_parser
......@@ -34,7 +34,7 @@ def run_daemon(lens, opts, args):
filters = [pattern.PatternExtractor(opts.pattern_file)]
while True:
try:
inputf = io.read_fifo(opts.fifo)
inputf = ioutil.read_fifo(opts.fifo)
lens.insert(inputf, parser, filters)
except Exception, e:
log.error('FIFO reader died with exception: %s', str(e))
......@@ -47,7 +47,7 @@ def run_inject(lens, opts, args):
filters = [pattern.PatternExtractor(opts.pattern_file)]
for filename in args:
logging.info('injecting %s', filename)
lens.insert(io.read_file(filename), parser, filters)
lens.insert(ioutil.read_file(filename), parser, filters)
def do_search(lens, opts, args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment