ChainsAutomation / chains

Chains Automation
GNU General Public License v2.0
7 stars 4 forks source link

InfluxDB service does not properly encode special chars #25

Closed stianstr closed 8 years ago

stianstr commented 8 years ago

2016-01-29 09:02:03,480 INFO insert measures: [{'fields': {'value': 6.5}, 'tags': {u'name': u'Kj\xf8leskapet', u'service': u'a9a90194230e4c488780c995e c3f3c3b', u'device': u'sensor-fridge-temperature', u'type': u'temperature', 'event': u'change', u'location': u'Kj\xf8kken'}, 'time': '2016-01-29T09:02:03Z', ' measurement': u'temperature'}] 2016-01-29 09:02:03,485 ERROR Service crashed: 1230192mfaf 2016-01-29 09:02:03,493 ERROR <type 'exceptions.UnicodeEncodeError'>: Traceback (most recent call last): File "/srv/chains/lib/chains/service/runservice.py", line 51, in serviceObject.start(block=True) File "/usr/lib/python2.7/chains/service/init.py", line 122, in start self.listen() File "/usr/lib/python2.7/chains/common/amqp.py", line 483, in listen self.onMessage(topic, data, correlationId) File "/usr/lib/python2.7/chains/services/influx/init.py", line 92, in onMessage self.ix.insert(measures) File "/usr/lib/python2.7/chains/services/influx/cinflux.py", line 13, in insert self.client.write_points(data) File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 391, in write_points tags=tags) File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 436, in _write_points expected_response_code=204 File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 276, in write data=make_lines(data, precision).encode('utf-8'), File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 108, in make_lines value = _escape_tag(tags[tag_key]) File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 40, in _escape_tag tag = _get_unicode(tag, force=True) File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 77, in _get_unicode return str(data) UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 2: ordinal not in range(128)

stianstr commented 8 years ago

Fixed in 1e88aa44e0c538feed6de479367feb167caf1dc0