Module: check_mk
Branch: master
Commit: e57d794db916eab33d71889d3b25b93a53c7d5b5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e57d794db916ea…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 19 15:01:37 2017 +0100
5584 FIX Fixed exception when "Export List of Software packages as CSV file" is
enabled
When having the export of the software packages list via CSV enabled while execution
of the HW/SW inventory, an exception could happen in case the inventory data contained
special characters. The exception looked like this on the command line:
Traceback (most recent call last):
File "/omd/sites/stable/share/check_mk/modules/check_mk.py", line 4811, in
<module>
do_inv(hostnames)
File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 180, in
do_inv
do_inv_for(hostname)
File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 267, in
do_inv_for
run_inv_export_hooks(hostname, g_inv_tree)
File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 383, in
run_inv_export_hooks
inv_export[hookname]["export_function"](hostname, params, tree)
File "/omd/sites/stable/share/check_mk/inventory/export_software_csv", line
67, in inv_export_software_csv
out.write("%s\n" % separator.join(line))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in
position 1: ordinal not in range(128)
Change-Id: I961f759a2048198038a46dd345be96c96c051259
---
.werks/5584 | 27 +++++++++++++++++++++++++++
inventory/export_software_csv | 2 +-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/5584 b/.werks/5584
new file mode 100644
index 0000000..35a49f1
--- /dev/null
+++ b/.werks/5584
@@ -0,0 +1,27 @@
+Title: Fixed exception when "Export List of Software packages as CSV file" is
enabled
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i2
+Date: 1513692003
+
+When having the export of the software packages list via CSV enabled while execution
+of the HW/SW inventory, an exception could happen in case the inventory data contained
+special characters. The exception looked like this on the command line:
+
+Traceback (most recent call last):
+ File "/omd/sites/stable/share/check_mk/modules/check_mk.py", line 4811, in
<module>
+ do_inv(hostnames)
+ File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 180, in
do_inv
+ do_inv_for(hostname)
+ File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 267, in
do_inv_for
+ run_inv_export_hooks(hostname, g_inv_tree)
+ File "/omd/sites/stable/share/check_mk/modules/inventory.py", line 383, in
run_inv_export_hooks
+ inv_export[hookname]["export_function"](hostname, params, tree)
+ File "/omd/sites/stable/share/check_mk/inventory/export_software_csv", line
67, in inv_export_software_csv
+ out.write("%s\n" % separator.join(line))
+UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in
position 1: ordinal not in range(128)
+
diff --git a/inventory/export_software_csv b/inventory/export_software_csv
index fdc59b7..068866f 100644
--- a/inventory/export_software_csv
+++ b/inventory/export_software_csv
@@ -64,7 +64,7 @@ def inv_export_software_csv(hostname, params, tree):
line = []
for key in keys:
line.append(quote(package.get(key, "")))
- out.write("%s\n" % separator.join(line))
+ out.write(("%s\n" % separator.join(line)).encode("utf-8"))
inv_export['software_csv'] = {