K
K
klabuk0v2014-01-17 13:38:37
Python
klabuk0v, 2014-01-17 13:38:37

How to pass the correct string to the input to the Python script or correctly process what is passed in the script?

Comrades help out, the situation is as follows:
I am writing a Python 3 script to integrate Zabbix 2.2 and our local ServiceDesk system.
I configure Zabbix to work with an external script by analogy with this instruction: www.pagerduty.com/docs/guides/zabbix-integration-guide
The problem is that the input to the script instead of Russian characters comes with something similar to a unicode string, here:

['/etc/zabbix/alert.d//script.py', 
'[email protected]', 
'trigger', 
'name:No ping availability\nid:100100000013878\nstatus:PROBLEM\nhostname:sms\nip:192.168.47.122\nvalue:1\nevent_id:100100001782560\nseverity:High\n
inventoryname:Server for send SMS\n
inrussia:\udcd0\udcbf\udcd1\udc80\udcd0\udcbe\udcd1\udc81\udcd1\udc82\udcd0\udcbe\udcd0\udcb5 \udcd1\udc81\udcd0\udcbb\udcd0\udcbe\udcd0\udcb2\udcd0\udcbe \udcd0\udcbd\udcd0\udcb0 \udcd1\udc80\udcd1\udc83\udcd1\udc81\udcd1\udc81\udcd0\udcba\udcd0\udcbe\udcd0\udcbc.']

instead of obscure characters, I expect to see the following:
inrussia:простое слово на русском.
here are queries to the zabbix database in MySQL that may be useful:
mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+

show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

OS - debian wheezy 3.2.51-1 x86_64
MySQL - Server version: 5.5.31-0+wheezy1 (Debian) Python
3.2.3
Zabbix 2.2.0
script?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KPEBETKA, 2014-01-17
@KPEBETKA

Try it like this:

unicode('\u041b\u0435\u0432\u044b\u0435', 'unicode-escape')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question