openscap-daemon
openscap-daemon copied to clipboard
Can't save report to a file
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)
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
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.
Workaround: see EPEL Bugzilla