Name | pysonrpc JSON |
Version |
1.0.6
JSON |
| download |
home_page | |
Summary | JSON RPC Python client with autodiscovery and methods mapping |
upload_time | 2024-03-07 00:18:17 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | MIT License Copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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 OR COPYRIGHT HOLDERS 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. |
keywords |
python
json
rpc
setuptools
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
![GitHub](https://img.shields.io/github/license/vche/pysonrpc) [![Codecov](https://img.shields.io/codecov/c/github/vche/pysonrpc)](https://codecov.io/gh/vche/pysonrpc) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/vche/pysonrpc)](https://github.com/vche/pysonrpc/releases) [![PyPI](https://img.shields.io/pypi/v/pysonrpc)](https://pypi.org/project/pysonrpc/) [![Downloads](https://pepy.tech/badge/pysonrpc)](https://pepy.tech/project/pysonrpc)
## What's pysonrpc
JSON RPC python client module with a CLI and method auto detection.
For JSON RPC server with a schema, an url canbe specified so that the schema is read, detecting the list of methods
supported.
Attributes are dynamically created to allow methods to be called as attributes, including namespaces.
Examples with [kodi](https://kodi.tv/) json rpc client:
### CLI
```bash
# List all methods available, autodetected from the server url (for kodi, this is not a complete list)
pysonrpc -r http://127.0.0.1:8080/jsonrpc -a list
# List all methods available, autodetected from a server rpc method
pysonrpc -r http://127.0.0.1:8080/jsonrpc -am "JSONRPC.Introspect" list -s -f VideoLibrary.
# List all methods available, autodetected from a schema json file
pysonrpc -r http://127.0.0.1:8080/jsonrpc -f schema.json list
# List methods filtered with VideoLibrary
pysonrpc -r http://127.0.0.1:8080/jsonrpc -am "JSONRPC.Introspect" list -s -f VideoLibrary
# Get favaourites list
pysonrpc -r http://127.0.0.1:8080/jsonrpc -a run Favourites.GetFavourites
# Get information on movie 1419
pysonrpc -r http://127.0.0.1:8080/jsonrpc -a run -m VideoLibrary.GetMovieDetails -p '{"movieid": 1419}'
```
Help
```bash
usage: pysonrpc [-h] [--version] --url URL [--user USER] [--password PASSWORD] [--debug] [--method-discover] [--method-discover-path METHOD_DISCOVER_PATH]
[--method-file METHOD_FILE]
{list,run} ...
RPC client
positional arguments:
{list,run} commands
list List available methods
run Execute a method
options:
-h, --help show this help message and exit
--version, -v Display version
--url URL, -r URL Host url, e.g 'http://192.168.0.1:8080'
--user USER, -u USER username if using basic authentication
--password PASSWORD, -p PASSWORD
Password if using basic authentication
--debug, -d Enable debug logging
--method-discover, -a
Auto discover rpc methods at the specified endpoint url
--method-discover-path METHOD_DISCOVER_PATH
Specifies a path after the specified endpoint url to query for methods auto discovery
--method-file METHOD_FILE, -f METHOD_FILE
Discover methods from given json file
```
### Python module
```python
from pysonrpc import JsonRpcEndpoint
cli = JsonRpcEndpoint("http://127.0.0.1:8080/jsonrpc", user="user", password="pwd", schema_method="JSONRPC.Introspect")
#Running a method from name
result=cli.run_method("Favourites.GetFavourites")
result=cli.run_method("VideoLibrary.GetMovieDetails", movieid=1419)
#Running a method from attribute
result=cli.Favourites.GetFavourites()
result=cli.VideoLibrary.GetMovieDetails(movieid=1419)
```
## Development
Using [pixi](https://pixi.sh/)
```sh
# Install dependencies and pycliarr
pixi build
# Run the binary
pixi run pycliarr
# Or start a term
pixi shell
# Run tests
pixi run tests
#generate doc
pixi run doc
```
### Run tests
```sh
pixi run tox
```
If mypy fails due to missing import stubs:
```sh
.tox/checkers/bin/mypy --install-types
```
### TODO:
- better way for parameters ? (add a list arg for a method only)
- tests and coverage
Raw data
{
"_id": null,
"home_page": "",
"name": "pysonrpc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Vivien Chene <viv@vivc.org>",
"keywords": "python,json,rpc,setuptools",
"author": "",
"author_email": "Vivien Chene <viv@vivc.org>",
"download_url": "https://files.pythonhosted.org/packages/f3/69/6d8261f13fcee249d7d7768bcf8fc0c41f6c55935667d21ad0e5576b134d/pysonrpc-1.0.6.tar.gz",
"platform": null,
"description": "![GitHub](https://img.shields.io/github/license/vche/pysonrpc) [![Codecov](https://img.shields.io/codecov/c/github/vche/pysonrpc)](https://codecov.io/gh/vche/pysonrpc) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/vche/pysonrpc)](https://github.com/vche/pysonrpc/releases) [![PyPI](https://img.shields.io/pypi/v/pysonrpc)](https://pypi.org/project/pysonrpc/) [![Downloads](https://pepy.tech/badge/pysonrpc)](https://pepy.tech/project/pysonrpc)\n\n## What's pysonrpc\n\nJSON RPC python client module with a CLI and method auto detection.\n\nFor JSON RPC server with a schema, an url canbe specified so that the schema is read, detecting the list of methods\nsupported.\nAttributes are dynamically created to allow methods to be called as attributes, including namespaces.\n\nExamples with [kodi](https://kodi.tv/) json rpc client:\n\n### CLI\n\n```bash\n# List all methods available, autodetected from the server url (for kodi, this is not a complete list)\npysonrpc -r http://127.0.0.1:8080/jsonrpc -a list\n\n# List all methods available, autodetected from a server rpc method\npysonrpc -r http://127.0.0.1:8080/jsonrpc -am \"JSONRPC.Introspect\" list -s -f VideoLibrary.\n\n# List all methods available, autodetected from a schema json file\npysonrpc -r http://127.0.0.1:8080/jsonrpc -f schema.json list\n\n# List methods filtered with VideoLibrary\npysonrpc -r http://127.0.0.1:8080/jsonrpc -am \"JSONRPC.Introspect\" list -s -f VideoLibrary\n\n# Get favaourites list\npysonrpc -r http://127.0.0.1:8080/jsonrpc -a run Favourites.GetFavourites\n\n# Get information on movie 1419\npysonrpc -r http://127.0.0.1:8080/jsonrpc -a run -m VideoLibrary.GetMovieDetails -p '{\"movieid\": 1419}'\n```\n\nHelp\n```bash\n usage: pysonrpc [-h] [--version] --url URL [--user USER] [--password PASSWORD] [--debug] [--method-discover] [--method-discover-path METHOD_DISCOVER_PATH]\n [--method-file METHOD_FILE]\n {list,run} ...\n\nRPC client\n\npositional arguments:\n {list,run} commands\n list List available methods\n run Execute a method\n\noptions:\n -h, --help show this help message and exit\n --version, -v Display version\n --url URL, -r URL Host url, e.g 'http://192.168.0.1:8080'\n --user USER, -u USER username if using basic authentication\n --password PASSWORD, -p PASSWORD\n Password if using basic authentication\n --debug, -d Enable debug logging\n --method-discover, -a\n Auto discover rpc methods at the specified endpoint url\n --method-discover-path METHOD_DISCOVER_PATH\n Specifies a path after the specified endpoint url to query for methods auto discovery\n --method-file METHOD_FILE, -f METHOD_FILE\n Discover methods from given json file\n```\n\n### Python module\n\n```python\nfrom pysonrpc import JsonRpcEndpoint\n\ncli = JsonRpcEndpoint(\"http://127.0.0.1:8080/jsonrpc\", user=\"user\", password=\"pwd\", schema_method=\"JSONRPC.Introspect\")\n\n#Running a method from name\nresult=cli.run_method(\"Favourites.GetFavourites\")\nresult=cli.run_method(\"VideoLibrary.GetMovieDetails\", movieid=1419)\n\n#Running a method from attribute\nresult=cli.Favourites.GetFavourites()\nresult=cli.VideoLibrary.GetMovieDetails(movieid=1419)\n```\n\n## Development\n\nUsing [pixi](https://pixi.sh/)\n\n```sh\n# Install dependencies and pycliarr\npixi build\n\n# Run the binary\npixi run pycliarr\n\n# Or start a term\npixi shell\n\n# Run tests\npixi run tests\n\n#generate doc\npixi run doc\n```\n\n### Run tests\n\n```sh\npixi run tox\n```\n\nIf mypy fails due to missing import stubs:\n```sh\n.tox/checkers/bin/mypy --install-types\n```\n\n### TODO:\n- better way for parameters ? (add a list arg for a method only)\n- tests and coverage\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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 OR COPYRIGHT HOLDERS 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. ",
"summary": "JSON RPC Python client with autodiscovery and methods mapping",
"version": "1.0.6",
"project_urls": {
"Bug Reports": "https://github.com/vche/pysonrpc/issues",
"Homepage": "https://github.com/vche/pysonrpc",
"Source": "https://github.com/vche/pysonrpc"
},
"split_keywords": [
"python",
"json",
"rpc",
"setuptools"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "28e04d49f97b47d8c3b9ea843d25e7ed4dd54a2d731718a1e052ae97cb6ba2a4",
"md5": "0adb2a9f4ec0ed7aaeac10c054f3be3b",
"sha256": "c61d1efccea08ac87faf9b2a0d9de6615ff61128a843160ef1cb198a9bc33893"
},
"downloads": -1,
"filename": "pysonrpc-1.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0adb2a9f4ec0ed7aaeac10c054f3be3b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9737,
"upload_time": "2024-03-07T00:18:15",
"upload_time_iso_8601": "2024-03-07T00:18:15.286581Z",
"url": "https://files.pythonhosted.org/packages/28/e0/4d49f97b47d8c3b9ea843d25e7ed4dd54a2d731718a1e052ae97cb6ba2a4/pysonrpc-1.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f3696d8261f13fcee249d7d7768bcf8fc0c41f6c55935667d21ad0e5576b134d",
"md5": "fd76ccd1c79c1ef3f16b2bfeba83530b",
"sha256": "1307c027deb30455980c747b95225f4d3a19c4d3e0c98e967c2fbf5ceefb4712"
},
"downloads": -1,
"filename": "pysonrpc-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "fd76ccd1c79c1ef3f16b2bfeba83530b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 13629,
"upload_time": "2024-03-07T00:18:17",
"upload_time_iso_8601": "2024-03-07T00:18:17.322251Z",
"url": "https://files.pythonhosted.org/packages/f3/69/6d8261f13fcee249d7d7768bcf8fc0c41f6c55935667d21ad0e5576b134d/pysonrpc-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-07 00:18:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vche",
"github_project": "pysonrpc",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pysonrpc"
}