Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-JSON payloads #16

Open
bergie opened this issue May 5, 2017 · 1 comment
Open

Allow non-JSON payloads #16

bergie opened this issue May 5, 2017 · 1 comment

Comments

@bergie
Copy link
Member

bergie commented May 5, 2017

Currently msgflo-python fails if payloads can't be serialized as JSON:

Traceback (most recent call last):
  File "/home/bergie/.local/lib/python2.7/site-packages/gevent/greenlet.py", line 536, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/bergie/Projects/c-base/farbgeber/farbgeber.py", line 107, in loop
    self.send_palette(palette)
  File "/home/bergie/Projects/c-base/farbgeber/farbgeber.py", line 128, in send_palette
    self.send('palette', palette)
  File "/home/bergie/.local/lib/python2.7/site-packages/msgflo/msgflo.py", line 54, in send
    self._engine._send(outport, outdata)
  File "/home/bergie/.local/lib/python2.7/site-packages/msgflo/msgflo.py", line 234, in _send
    serialized = json.dumps(data)
  File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <Color #cc5d00> is not JSON serializable
@bergie
Copy link
Member Author

bergie commented May 7, 2017

Also would be nice to be able to send strings as-is. Now they become quoted.

So when sending hello world, the MQTT topic gets "hello world"

bergie referenced this issue in c-base/mqttwebview May 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants