diff --git a/platypush/backend/local/__init__.py b/platypush/backend/local/__init__.py index b77105e99..9e3861698 100644 --- a/platypush/backend/local/__init__.py +++ b/platypush/backend/local/__init__.py @@ -12,8 +12,22 @@ from platypush.message.request import Request from platypush.message.response import Response class LocalBackend(Backend): - """ Sends and receive messages on two distinct local FIFOs, one for - the requests and one for the responses """ + """ + Sends and receive messages on two distinct local FIFOs, one for + the requests and one for the responses. + + You can use this backend either to send local commands to push through + Pusher (or any other script), or debug. You can even send command on the + command line and read the responses in this way: + + # Send the request. Remember: the JSON must be all on one line. + $ cat < /tmp/platypush-requests.fifo + {"type": "request", "target": "node_name", "action": "shell.exec", "args": {"cmd":"echo ping"}, "origin": "node_name", "id": "put_an_id_here"} + EOF + $ cat /tmp/platypush-responses.fifo + ping + $ + """ def __init__(self, request_fifo, response_fifo, **kwargs): super().__init__(**kwargs) diff --git a/tests/test_local.py b/tests/test_local.py index 2fed77550..bf0956909 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -1,5 +1,6 @@ from .context import platypush, config_file, TestTimeoutException +import os import sys import logging import unittest @@ -22,6 +23,12 @@ class TestLocal(unittest.TestCase): backends = Config.get_backends() self.assertTrue('local' in backends) + try: os.remove(Config.get_backends()['local']['request_fifo']) + except FileNotFoundError as e: pass + + try: os.remove(Config.get_backends()['local']['response_fifo']) + except FileNotFoundError as e: pass + def test_local_shell_exec_flow(self): self.start_sender()