zmqcli


Namezmqcli JSON
Version 0.9.7 PyPI version JSON
download
home_pagehttps://gitlab.com/tamtamresearch-public/pypi/zmqcli
SummaryA small but powerful command-line interface to ZeroMQ.
upload_time2023-07-11 19:39:05
maintainerRoman Horenovsky
docs_urlNone
authorTamTam Research s.r.o.
requires_python>=3.7,<4.0
licenseUnlicense
keywords zeromq cli ømq 0mq zmq
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # zmqcli

zmqcli is a small but powerful command-line interface to [ØMQ][zmq] written in Python 3.

It allows you to create a socket of a given type, bind or connect it to multiple
addresses, set options on it, and receive or send messages over it using
standard I/O, in the shell or in scripts.

It's useful for debugging and
experimenting with most possible network topologies.

  [zmq]: http://www.zeromq.org/

## Installation

    pip install zmqcli


## Usage

    zmqcli [-h] [-v] [-0] [-r | -w] (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]

Executing the command as a module is also supported:

    python -m zmqcli [-h] [-v] [-0] [-r | -w] (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]


### Mode

<dl>
  <p>
    Whether to read from or write to the socket. For PUB/SUB sockets, this
    option is invalid since the behavior will always be write and read
    respectively. For REQ/REP sockets, zmqcli will alternate between reading and
    writing as part of the request/response cycle.
  </p>

  <dt>-r, --read</dt>
    <dd>Read messages from the socket onto stdout.</dd>

  <dt>-w, --write</dt>
    <dd>Write messages from stdin to the socket.</dd>
</dl>


### Behavior

<dl>
  <dt>-b, --bind</dt>
    <dd>Bind to the specified address(es).</dd>
  <dt>-c, --connect</dt>
    <dd>Connect to the specified address(es).</dd>
</dl>


### Socket Parameters

<dl>
  <dt>SOCK_TYPE</dt>
  <dd>
    Which type of socket to create. Must be one of `PUSH`, `PULL`, `PUB`,
    `SUB`, `REQ`, `REP` or `PAIR`. See `man zmq_socket` for an explanation of
    the different types. `DEALER` and `ROUTER` sockets are currently
    unsupported.
  </dd>
  <dt>-o SOCK_OPT=VALUE, --option SOCK_OPT=VALUE</dt>
  <dd>
    Socket option names and values to set on the created socket. Consult `man
    zmq_setsockopt` for a comprehensive list of options. Note that you can
    safely omit the `ZMQ_` prefix from the option name. If the created socket
    is of type `SUB`, and no `SUBSCRIBE` options are given, the socket will
    automatically be subscribed to everything.
  </dd>
  <dt>address</dt>
  <dd>
    One or more addresses to bind/connect to. Must be in full ZMQ format (e.g.
    `tcp://&lt;host&gt;:&lt;port&gt;`)
  </dd>
</dl>


## Examples

    zmqcli -rc SUB 'tcp://127.0.0.1:5000'

Subscribe to `tcp://127.0.0.1:5000`, reading messages from it and printing them
to the console. This will subscribe to all messages by default (you don't need
to set an empty `SUBSCRIBE` option). Alternatively:

    zmqcli -rc SUB -o SUBSCRIBE='com.organization.' 'tcp://127.0.0.1:5000'

This will subscribe to all messages starting with `com.organization.`.

* * * *

    ls | zmqcli -wb PUSH 'tcp://*:4000'

Send the name of every file in the current directory as a message from a PUSH
socket bound to port 4000 on all interfaces. Don't forget to quote the address
to avoid glob expansion.

* * * *

    zmqcli -rc PULL 'tcp://127.0.0.1:5202' | tee $TTY | zmqcli -wc PUSH 'tcp://127.0.0.1:5404'

Read messages coming from a PUSH socket bound to port 5202 (note that we're
connecting with a PULL socket), echo them to the active console, and forward
them to a PULL socket bound to port 5404 (so we're connecting with a PUSH).

* * * *

    zmqcli -n 10 -0rb PULL 'tcp://*:4123' | xargs -0 grep 'pattern'

Bind to a PULL socket on port 4123, receive 10 messages from the socket
(with each message representing a filename), and grep the files for
`'pattern'`. The `-0` option means messages will be NULL-delimited rather
than separated by newlines, so that filenames with spaces in them are not
considered two separate arguments by xargs.

* * * *

    echo "hello" | zmqcli -c REQ 'tcp://127.0.0.1:4000'

Send the string `hello` through a REQ socket connected to localhost on port
4000, print whatever you get back, and finish. In this way, REQ sockets can
be used for a rudimentary form of RPC in shell scripts.

* * * *

    coproc zmqcli -b REP 'tcp://*:4000'
    tr -u '[a-z]' '[A-Z]' <&p >&p &
    echo "hello" | zmqcli -c REQ 'tcp://127.0.0.1:4000'

First, start a REP socket listening on port 4000. The `coproc` shell command
runs this as a shell coprocess, which allows us to run the next line, tr. This
will read its input from the REP socket's output, translate all lowercase
characters to uppercase, and send them back to the REP socket's input. This,
again, is run in the background. Finally, connect a REQ socket to that REP
socket and send the string `hello` through it: you should just see the string
`HELLO` printed on stdout.

* * * *
Pingy exchange example

Sending ping lines from ping command -> PUSH -> PULL -> PUB -> SUB -> stdout:

Source of ping records:

    ping google.com | zmqcli -w -c PUSH tcp://127.0.0.1:5001 

Broker:

    zmqcli -r -b PULL tcp://*:5001 | zmqcli -w -b PUB tcp://*:5002 

Consumer:

    python -m zmqcli -r -c SUB tcp://127.0.0.1:5002

the consumer can be run in multiple instances reporting always the same records.

## Credits

Based on the work of [Zachary Voase](https://github.com/zacharyvoase), the author of the original [zmqc](https://github.com/zacharyvoase/zmqc) tool.

## (Un)license

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/tamtamresearch-public/pypi/zmqcli",
    "name": "zmqcli",
    "maintainer": "Roman Horenovsky",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "ZeroMQ,CLI,\u00d8MQ,0MQ,zmq",
    "author": "TamTam Research s.r.o.",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/86/b3/6dc1b9d2f69263e1397cd72b3f86eb0de23b52753b81ea8b2f54fd85f12b/zmqcli-0.9.7.tar.gz",
    "platform": null,
    "description": "# zmqcli\n\nzmqcli is a small but powerful command-line interface to [\u00d8MQ][zmq] written in Python 3.\n\nIt allows you to create a socket of a given type, bind or connect it to multiple\naddresses, set options on it, and receive or send messages over it using\nstandard I/O, in the shell or in scripts.\n\nIt's useful for debugging and\nexperimenting with most possible network topologies.\n\n  [zmq]: http://www.zeromq.org/\n\n## Installation\n\n    pip install zmqcli\n\n\n## Usage\n\n    zmqcli [-h] [-v] [-0] [-r | -w] (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]\n\nExecuting the command as a module is also supported:\n\n    python -m zmqcli [-h] [-v] [-0] [-r | -w] (-b | -c) SOCK_TYPE [-o SOCK_OPT=VALUE...] address [address ...]\n\n\n### Mode\n\n<dl>\n  <p>\n    Whether to read from or write to the socket. For PUB/SUB sockets, this\n    option is invalid since the behavior will always be write and read\n    respectively. For REQ/REP sockets, zmqcli will alternate between reading and\n    writing as part of the request/response cycle.\n  </p>\n\n  <dt>-r, --read</dt>\n    <dd>Read messages from the socket onto stdout.</dd>\n\n  <dt>-w, --write</dt>\n    <dd>Write messages from stdin to the socket.</dd>\n</dl>\n\n\n### Behavior\n\n<dl>\n  <dt>-b, --bind</dt>\n    <dd>Bind to the specified address(es).</dd>\n  <dt>-c, --connect</dt>\n    <dd>Connect to the specified address(es).</dd>\n</dl>\n\n\n### Socket Parameters\n\n<dl>\n  <dt>SOCK_TYPE</dt>\n  <dd>\n    Which type of socket to create. Must be one of `PUSH`, `PULL`, `PUB`,\n    `SUB`, `REQ`, `REP` or `PAIR`. See `man zmq_socket` for an explanation of\n    the different types. `DEALER` and `ROUTER` sockets are currently\n    unsupported.\n  </dd>\n  <dt>-o SOCK_OPT=VALUE, --option SOCK_OPT=VALUE</dt>\n  <dd>\n    Socket option names and values to set on the created socket. Consult `man\n    zmq_setsockopt` for a comprehensive list of options. Note that you can\n    safely omit the `ZMQ_` prefix from the option name. If the created socket\n    is of type `SUB`, and no `SUBSCRIBE` options are given, the socket will\n    automatically be subscribed to everything.\n  </dd>\n  <dt>address</dt>\n  <dd>\n    One or more addresses to bind/connect to. Must be in full ZMQ format (e.g.\n    `tcp://&lt;host&gt;:&lt;port&gt;`)\n  </dd>\n</dl>\n\n\n## Examples\n\n    zmqcli -rc SUB 'tcp://127.0.0.1:5000'\n\nSubscribe to `tcp://127.0.0.1:5000`, reading messages from it and printing them\nto the console. This will subscribe to all messages by default (you don't need\nto set an empty `SUBSCRIBE` option). Alternatively:\n\n    zmqcli -rc SUB -o SUBSCRIBE='com.organization.' 'tcp://127.0.0.1:5000'\n\nThis will subscribe to all messages starting with `com.organization.`.\n\n* * * *\n\n    ls | zmqcli -wb PUSH 'tcp://*:4000'\n\nSend the name of every file in the current directory as a message from a PUSH\nsocket bound to port 4000 on all interfaces. Don't forget to quote the address\nto avoid glob expansion.\n\n* * * *\n\n    zmqcli -rc PULL 'tcp://127.0.0.1:5202' | tee $TTY | zmqcli -wc PUSH 'tcp://127.0.0.1:5404'\n\nRead messages coming from a PUSH socket bound to port 5202 (note that we're\nconnecting with a PULL socket), echo them to the active console, and forward\nthem to a PULL socket bound to port 5404 (so we're connecting with a PUSH).\n\n* * * *\n\n    zmqcli -n 10 -0rb PULL 'tcp://*:4123' | xargs -0 grep 'pattern'\n\nBind to a PULL socket on port 4123, receive 10 messages from the socket\n(with each message representing a filename), and grep the files for\n`'pattern'`. The `-0` option means messages will be NULL-delimited rather\nthan separated by newlines, so that filenames with spaces in them are not\nconsidered two separate arguments by xargs.\n\n* * * *\n\n    echo \"hello\" | zmqcli -c REQ 'tcp://127.0.0.1:4000'\n\nSend the string `hello` through a REQ socket connected to localhost on port\n4000, print whatever you get back, and finish. In this way, REQ sockets can\nbe used for a rudimentary form of RPC in shell scripts.\n\n* * * *\n\n    coproc zmqcli -b REP 'tcp://*:4000'\n    tr -u '[a-z]' '[A-Z]' <&p >&p &\n    echo \"hello\" | zmqcli -c REQ 'tcp://127.0.0.1:4000'\n\nFirst, start a REP socket listening on port 4000. The `coproc` shell command\nruns this as a shell coprocess, which allows us to run the next line, tr. This\nwill read its input from the REP socket's output, translate all lowercase\ncharacters to uppercase, and send them back to the REP socket's input. This,\nagain, is run in the background. Finally, connect a REQ socket to that REP\nsocket and send the string `hello` through it: you should just see the string\n`HELLO` printed on stdout.\n\n* * * *\nPingy exchange example\n\nSending ping lines from ping command -> PUSH -> PULL -> PUB -> SUB -> stdout:\n\nSource of ping records:\n\n    ping google.com | zmqcli -w -c PUSH tcp://127.0.0.1:5001 \n\nBroker:\n\n    zmqcli -r -b PULL tcp://*:5001 | zmqcli -w -b PUB tcp://*:5002 \n\nConsumer:\n\n    python -m zmqcli -r -c SUB tcp://127.0.0.1:5002\n\nthe consumer can be run in multiple instances reporting always the same records.\n\n## Credits\n\nBased on the work of [Zachary Voase](https://github.com/zacharyvoase), the author of the original [zmqc](https://github.com/zacharyvoase/zmqc) tool.\n\n## (Un)license\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\n\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nAUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <http://unlicense.org/>\n",
    "bugtrack_url": null,
    "license": "Unlicense",
    "summary": "A small but powerful command-line interface to ZeroMQ.",
    "version": "0.9.7",
    "project_urls": {
        "Documentation": "https://gitlab.com/tamtamresearch-public/pypi/zmqcli",
        "Homepage": "https://gitlab.com/tamtamresearch-public/pypi/zmqcli",
        "Repository": "https://gitlab.com/tamtamresearch-public/pypi/zmqcli"
    },
    "split_keywords": [
        "zeromq",
        "cli",
        "\u00f8mq",
        "0mq",
        "zmq"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6afafb11d43afe6d7118f56b5b959ab85e4c8c00a513489d52ea805e73e4bd22",
                "md5": "7490fac084ed83cbb5f23372452f2b77",
                "sha256": "b1c1626bff06738258cc65bb50c59e0781560fd630c1fa4d505b581434213177"
            },
            "downloads": -1,
            "filename": "zmqcli-0.9.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7490fac084ed83cbb5f23372452f2b77",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 9971,
            "upload_time": "2023-07-11T19:39:04",
            "upload_time_iso_8601": "2023-07-11T19:39:04.148863Z",
            "url": "https://files.pythonhosted.org/packages/6a/fa/fb11d43afe6d7118f56b5b959ab85e4c8c00a513489d52ea805e73e4bd22/zmqcli-0.9.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86b36dc1b9d2f69263e1397cd72b3f86eb0de23b52753b81ea8b2f54fd85f12b",
                "md5": "9dd51f8edc7d251acf6d35923613e7c5",
                "sha256": "4ea70e8f96db53be11c83d60920015df598dcbf8a7310c21bf1dc050badbb163"
            },
            "downloads": -1,
            "filename": "zmqcli-0.9.7.tar.gz",
            "has_sig": false,
            "md5_digest": "9dd51f8edc7d251acf6d35923613e7c5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 8224,
            "upload_time": "2023-07-11T19:39:05",
            "upload_time_iso_8601": "2023-07-11T19:39:05.544636Z",
            "url": "https://files.pythonhosted.org/packages/86/b3/6dc1b9d2f69263e1397cd72b3f86eb0de23b52753b81ea8b2f54fd85f12b/zmqcli-0.9.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 19:39:05",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "tamtamresearch-public",
    "gitlab_project": "pypi",
    "lcname": "zmqcli"
}
        
Elapsed time: 0.10124s