OpenSCAP / openscap-daemon

Manages continuous scans of your infrastructure
https://www.open-scap.org/tools/openscap-daemon
GNU Lesser General Public License v2.1
106 stars 32 forks source link

Can't save report to a file #123

Open wiredaem0n opened 6 years ago

wiredaem0n commented 6 years ago

Getting the following error when trying to save report to a file. Note that running the report without redirecting the output to a file works.

# oscapd-cli result 1 1 report > sample-report.html Traceback (most recent call last): File "/bin/oscapd-cli", line 846, in <module> main() File "/bin/oscapd-cli", line 838, in main cli_result(dbus_iface, args) File "/bin/oscapd-cli", line 466, in cli_result print(report) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 223106: ordinal not in range(128)

matejak commented 6 years ago

It is a somewhat tricky issue - Python doesn't know the encoding of the file you are trying to write, and this is a problem for python2. Although it can be fixed in a smarter way, you can try this quick fix: PYTHONIOENCODING=UTF-8 oscapd-cli result 1 1 report > sample-report.html

matejak commented 6 years ago

I think that as we write an HTML file, we know that we use the UTF8 encoding, so it should be fixed in the code.

tuxmaster commented 6 years ago

Workaround: see EPEL Bugzilla