Commit 5b441e84 authored by Titouan Soulard's avatar Titouan Soulard

check_slow_queries_digest_result: fix encoding on file opening

Sometimes, it seems the file analyzed can contain non-ASCII characters, giving
errors such as:

```
codec can't decode byte 0xc3 in position 5138: ordinal not in range(128)
```

It seems there is no reason to not support UTF8, and more generally ignore
encoding errors here. This change has been applied for a few weeks on Nexedi
ERP5 production without problems.

/reviewed-by @tomo @jerome
/reviewed-on !140
/cc @xavier_thompson
parent b7cea990
......@@ -28,7 +28,7 @@ def checkMariadbDigestResult(mariadbdex_path, mariadbdex_report_status_file,
else:
for date in today_or_yesterday:
if mariadbdex_file == date.strftime('slowquery_digest.txt-%Y-%m-%d.xz'):
with lzma.open(os.path.join(mariadbdex_path, mariadbdex_file), 'rt') as f:
with lzma.open(os.path.join(mariadbdex_path, mariadbdex_file), 'rt', encoding='utf8', errors='ignore') as f:
content = f.read()
if content:
# XXX: if not a lot of usage, skip this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment