@cryptotaxi247 / netdata-1 / commits / 4d1b5f2c8

web_log plugin: python 2.6 compatability fix

Ilya committed Feb 15, 2017 at 09:24 UTC 4d1b5f2c80043dac66262866183c30f434010870
1 file changed +11 -2
python.d/web_log.chart.py
+11 -2
@@ -128,12 +128,21 @@ class Service(LogService):
128 logs.seek(-2, 1)
129 if logs.tell() == 0:
130 break
131 - last_line = logs.readline().decode(encoding='utf-8')
131 + last_line = logs.readline()
132 +
133 + try:
134 + last_line = last_line.decode()
135 + except UnicodeDecodeError:
136 + try:
137 + last_line = last_line.decode(encoding='utf-8')
138 + except (TypeError, UnicodeDecodeError) as error:
139 + self.error(str(error))
140 + return False
141
142 # Parse last line
143 regex_name = self.find_regex(last_line)
144 if not regex_name:
136 - self.error('Can\'t parse %s' % self.log_path)
145 + self.error('Unknown log format. Can\'t parse %s' % self.log_path)
146 return False
147
148 if regex_name.startswith('acs_'):