]> arthur.barton.de Git - netdata.git/commitdiff
web_log plugin: python 2.6 compatability fix
authorIlya <ilyamaschenko@gmail.com>
Wed, 15 Feb 2017 00:24:38 +0000 (09:24 +0900)
committerIlya <ilyamaschenko@gmail.com>
Wed, 15 Feb 2017 00:24:38 +0000 (09:24 +0900)
python.d/web_log.chart.py

index 9119c9dc774d934f2ec96e13a98bd215978e3ab8..43abdf033d617371a72b5d2bcf04796817691ae4 100644 (file)
@@ -128,12 +128,21 @@ class Service(LogService):
                 logs.seek(-2, 1)
                 if logs.tell() == 0:
                     break
-            last_line = logs.readline().decode(encoding='utf-8')
+            last_line = logs.readline()
+
+        try:
+            last_line = last_line.decode()
+        except UnicodeDecodeError:
+            try:
+                last_line = last_line.decode(encoding='utf-8')
+            except (TypeError, UnicodeDecodeError) as error:
+                self.error(str(error))
+                return False
 
         # Parse last line
         regex_name = self.find_regex(last_line)
         if not regex_name:
-            self.error('Can\'t parse %s' % self.log_path)
+            self.error('Unknown log format. Can\'t parse %s' % self.log_path)
             return False
 
         if regex_name.startswith('acs_'):