[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Gerhard Lausser gerhard.lausser at consol.de
Tue Feb 28 22:08:18 UTC 2012


The following commit has been merged in the debian/master branch:
commit 1116e0257535e33fa4fa1dfe954e545460e9302d
Author: Gerhard Lausser <gerhard.lausser at consol.de>
Date:   Fri Dec 9 01:34:15 2011 +0100

    fix the bugfix. (some hot advice for masochists: catch a bad cold and keep struggling with éncôding)

diff --git a/shinken/modules/livestatus_broker/livestatus_response.py b/shinken/modules/livestatus_broker/livestatus_response.py
index 5500f15..7e26013 100644
--- a/shinken/modules/livestatus_broker/livestatus_response.py
+++ b/shinken/modules/livestatus_broker/livestatus_response.py
@@ -69,8 +69,6 @@ class LiveStatusResponse:
         showheader = False
         #print "my result is", result
         print "outputformat", self.outputformat
-        stdout_encoding = sys.getdefaultencoding()
-        #stdout_encoding = "UTF-8"
         if self.outputformat == 'csv':
             if len(columns) == 0:
                 # There is no pre-selected list of columns. In this case
@@ -81,10 +79,13 @@ class LiveStatusResponse:
                     for x in [object[c] for c in sorted(object.keys())]:
                         if isinstance(x, list):
                             l.append(self.separators[2].join(str(y) for y in x))
-                        elif isinstance(x, basestring):
-                            l.append(x.encode(stdout_encoding, 'replace'))
                         else:
-                            l.append(str(x))
+                            try:
+                                l.append(str(x))
+                            except UnicodeEncodeError:
+                                l.append(x.encode("utf-8", "replace"))
+                            except Exception:
+                                l.append("")
                     lines.append(self.separators[1].join(l))
             else:
                 for object in result:
@@ -93,10 +94,13 @@ class LiveStatusResponse:
                     for x in [object[c] for c in columns]:
                         if isinstance(x, list):
                             l.append(self.separators[2].join(str(y) for y in x))
-                        elif isinstance(x, basestring):
-                            l.append(x.encode(stdout_encoding, 'replace'))
                         else:
-                            l.append(str(x))
+                            try:
+                                l.append(str(x))
+                            except UnicodeEncodeError:
+                                l.append(x.encode("utf-8", "replace"))
+                            except Exception:
+                                l.append("")
                     lines.append(self.separators[1].join(l))
             if len(lines) > 0:
                 if self.columnheaders != 'off' or len(columns) == 0:

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list