Closed ikonovalenko closed 5 years ago
Resolved this by changing zabbix-cachet.py
from return yaml.safe_load(open(config_f, "r"))
to return yaml.safe_load(open(config_f, "r+", encoding="utf-8"))
.
Not sure if it helps, but zabbix-cachet at least runs now.
Can not reproduce. Use cyrillic letters in templates/acknowledgement. Works as expected.
What exactly you have in templates?
Currently, templates are encoded in utf-8 and in console it looks like:
resolving: "Проблема решена - {time}\n\n__\n"
Can you please show me your file and output of file -bi config.yml
command.
For mine config.yml:
[root@status zabbix-cachet]# file -bi config.yml
text/x-c++; charset=utf-8
Hi,
Can you please show me your file and output of file -bi config.yml command.
qk4l: ~/g/zabbix-cachet> file -bi config.yml text/plain; charset=utf-8
Hello,
I am trying to use non-latin symbols in templates. Tried ansi and utf-8 charset, however, for anything non-latin zabbix-cachet.py responds with an error:
[root@status zabbix-cachet]# ./zabbix-cachet.py Traceback (most recent call last): File "./zabbix-cachet.py", line 675, in <module> config = read_config(CONFIG_F) File "./zabbix-cachet.py", line 664, in read_config return yaml.safe_load(open(config_f, "r")) File "/usr/lib64/python3.4/site-packages/yaml/__init__.py", line 94, in safe_load return load(stream, SafeLoader) File "/usr/lib64/python3.4/site-packages/yaml/__init__.py", line 70, in load loader = Loader(stream) File "/usr/lib64/python3.4/site-packages/yaml/loader.py", line 24, in __init__ Reader.__init__(self, stream) File "/usr/lib64/python3.4/site-packages/yaml/reader.py", line 85, in __init__ self.determine_encoding() File "/usr/lib64/python3.4/site-packages/yaml/reader.py", line 124, in determine_encoding self.update_raw() File "/usr/lib64/python3.4/site-packages/yaml/reader.py", line 178, in update_raw data = self.stream.read(size) File "/usr/lib64/python3.4/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xee in position 1015: ordinal not in range(128)