Message11558

Author birkoff
Recipients birkoff
Date 2017-08-31.13:37:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504186630.47.0.857302789103.issue2622@psf.upfronthosting.co.za>
In-reply-to
Content
When I use PyZabbix ( https://github.com/adubkov/py-zabbix ) with simple code:

from pyzabbix import ZabbixMetric, ZabbixSender

# Send metrics to zabbix trapper
packet = [
    ZabbixMetric('hostname', 'test', 1),
]

result = ZabbixSender('127.0.0.1').send(packet)

Get error

Traceback (most recent call last):
  File "zabbix.py", line 8, in <module>
    result = ZabbixSender('127.0.0.1').send(packet)
  File "D:\Codes\zpy\pyzabbix\sender.py", line 383, in send
    result.parse(self._chunk_send(metrics[m:m + self.chunk_size]))
  File "D:\Codes\zpy\pyzabbix\sender.py", line 341, in _chunk_send
    messages = self._create_messages(metrics)
  File "D:\Codes\zpy\pyzabbix\sender.py", line 254, in _create_messages
    messages.append(str(m))
  File "D:\Codes\zpy\pyzabbix\sender.py", line 128, in __repr__
    result = json.dumps(self.__dict__)
  File "D:\Codes\zpy\jython-standalone-2.7.1.jar\Lib\json\__init__.py", line 243, in dumps
  File "D:\Codes\zpy\jython-standalone-2.7.1.jar\Lib\json\encoder.py", line 206, in encode
  File "D:\Codes\zpy\jython-standalone-2.7.1.jar\Lib\json\encoder.py", line 269, in iterencode
  File "D:\Codes\zpy\jython-standalone-2.7.1.jar\Lib\json\encoder.py", line 183, in default
TypeError: {'host': 'hostname', 'value': '1', 'key': 'test'} is not JSON serializable

---

On cpython 2.7.10 all work perfect

---

import json

data = {'host': 'hostname', 'value': '1', 'key': 'test'}

jsonf = json.dumps (data)

In Jython 2.7.1 works without any errors.
History
Date User Action Args
2017-08-31 13:37:10birkoffsetrecipients: + birkoff
2017-08-31 13:37:10birkoffsetmessageid: <1504186630.47.0.857302789103.issue2622@psf.upfronthosting.co.za>
2017-08-31 13:37:10birkofflinkissue2622 messages
2017-08-31 13:37:09birkoffcreate