Skip to content
Snippets Groups Projects
Commit b81d252c authored by Pavel Kácha's avatar Pavel Kácha
Browse files

LaBrea: Open log with safe encoding - avoid bytes -> str errors

parent 5183c922
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import time ...@@ -8,6 +8,7 @@ import time
import optparse import optparse
import signal import signal
import uuid import uuid
import codecs
import json import json
import socket import socket
import resource import resource
...@@ -210,7 +211,7 @@ class FileWatcher(object): ...@@ -210,7 +211,7 @@ class FileWatcher(object):
def open(self): def open(self):
try: try:
self.f = open(self.filename, "r") self.f = codecs.open(self.filename, "r", encoding="ISO-8859-1")
st = os.fstat(self.f.fileno()) st = os.fstat(self.f.fileno())
self.inode, self.size = st.st_ino, st.st_size self.inode, self.size = st.st_ino, st.st_size
except IOError: except IOError:
...@@ -662,7 +663,7 @@ def main(): ...@@ -662,7 +663,7 @@ def main():
if opts.oneshot: if opts.oneshot:
signal.signal(signal.SIGINT, terminate_me) signal.signal(signal.SIGINT, terminate_me)
signal.signal(signal.SIGTERM, terminate_me) signal.signal(signal.SIGTERM, terminate_me)
files = [open(arg) for arg in args] files = [codecs.open(arg, "r", encoding="ISO-8859-1") for arg in args]
else: else:
daemonize( daemonize(
pidfile=opts.pid, pidfile=opts.pid,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment