shvcli 0.8.0__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shvcli-0.9.0/PKG-INFO +267 -0
- shvcli-0.9.0/README.rst +219 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/pyproject.toml +34 -20
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/__init__.py +1 -1
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/__setuptools__.py +1 -1
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/__version__.py +4 -5
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/afterconn.py +1 -2
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/args.py +5 -6
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtin.py +14 -14
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/__init__.py +2 -2
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/broker.py +10 -10
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/cd.py +3 -3
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/file.py +13 -13
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/help.py +4 -4
- shvcli-0.9.0/shvcli/builtins/history.py +168 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/scan.py +3 -3
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/set.py +4 -4
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/builtins/tree.py +4 -4
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/cli.py +19 -6
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/client.py +31 -8
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/cliitems.py +12 -10
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/config.py +4 -5
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/file.py +6 -4
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/lsdir.py +16 -7
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/oauth.py +5 -5
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/option.py +27 -19
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/options.py +13 -14
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/plugins.py +1 -2
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/state.py +8 -10
- shvcli-0.9.0/shvcli/tools/cpon.py +197 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/tools/print.py +64 -76
- shvcli-0.9.0/shvcli/tools/rpctype.py +30 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/tree.py +1 -1
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/url.py +8 -8
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/valid.py +1 -1
- shvcli-0.9.0/shvcli.egg-info/PKG-INFO +267 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli.egg-info/SOURCES.txt +6 -1
- shvcli-0.9.0/shvcli.egg-info/requires.txt +9 -0
- shvcli-0.9.0/shvcli.egg-info/top_level.txt +4 -0
- shvcli-0.9.0/tests/__init__.py +0 -0
- shvcli-0.9.0/tests/tools/__init__.py +0 -0
- shvcli-0.9.0/tests/tools/test_cpon.py +270 -0
- shvcli-0.8.0/PKG-INFO +0 -249
- shvcli-0.8.0/README.rst +0 -204
- shvcli-0.8.0/shvcli/builtins/history.py +0 -146
- shvcli-0.8.0/shvcli.egg-info/PKG-INFO +0 -249
- shvcli-0.8.0/shvcli.egg-info/requires.txt +0 -5
- shvcli-0.8.0/shvcli.egg-info/top_level.txt +0 -2
- {shvcli-0.8.0 → shvcli-0.9.0}/LICENSE +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/setup.cfg +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/__main__.py +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/complet.py +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/py.typed +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/scan.py +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/tools/__init__.py +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli/tools/complet.py +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli.egg-info/dependency_links.txt +0 -0
- {shvcli-0.8.0 → shvcli-0.9.0}/shvcli.egg-info/entry_points.txt +0 -0
shvcli-0.9.0/PKG-INFO
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shvcli
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Silicon Heaven CLI access application
|
|
5
|
+
Author: Elektroline a.s.
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2023 Elektroline a.s.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: repository, https://gitlab.com/silicon-heaven/shvcli
|
|
29
|
+
Classifier: Development Status :: 4 - Beta
|
|
30
|
+
Classifier: Operating System :: OS Independent
|
|
31
|
+
Classifier: Environment :: Console
|
|
32
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
33
|
+
Classifier: Topic :: Home Automation
|
|
34
|
+
Classifier: Topic :: System :: Shells
|
|
35
|
+
Classifier: Topic :: Terminals
|
|
36
|
+
Requires-Python: >=3.12
|
|
37
|
+
Description-Content-Type: text/x-rst
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: pyshv>=0.14.0
|
|
40
|
+
Requires-Dist: prompt-toolkit
|
|
41
|
+
Requires-Dist: pygments
|
|
42
|
+
Requires-Dist: pyxdg
|
|
43
|
+
Requires-Dist: more-itertools
|
|
44
|
+
Provides-Extra: test
|
|
45
|
+
Requires-Dist: pytest; extra == "test"
|
|
46
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
#######################################
|
|
50
|
+
Silicon Heaven CLI access application
|
|
51
|
+
#######################################
|
|
52
|
+
|
|
53
|
+
.. image:: https://gitlab.com/silicon-heaven/shvcli/-/raw/master/logo.svg
|
|
54
|
+
:align: right
|
|
55
|
+
:height: 128px
|
|
56
|
+
|
|
57
|
+
This provides an easy to use CLI interfase to access the SHV network.
|
|
58
|
+
|
|
59
|
+
- `📃 Sources <https://gitlab.com/silicon-heaven/shvcli>`__
|
|
60
|
+
- `⁉️ Issue tracker <https://gitlab.com/silicon-heaven/shvcli/-/issues>`__
|
|
61
|
+
- `📕 Silicon Heaven protocol documentation
|
|
62
|
+
<https://silicon-heaven.github.io/shv-doc/>`__
|
|
63
|
+
|
|
64
|
+
**************
|
|
65
|
+
Installation
|
|
66
|
+
**************
|
|
67
|
+
|
|
68
|
+
The installation can be done with package manager ``pip``.
|
|
69
|
+
|
|
70
|
+
.. code-block:: console
|
|
71
|
+
|
|
72
|
+
$ pip install shvcli
|
|
73
|
+
|
|
74
|
+
Documentation
|
|
75
|
+
=============
|
|
76
|
+
|
|
77
|
+
*******
|
|
78
|
+
Usage
|
|
79
|
+
*******
|
|
80
|
+
|
|
81
|
+
You need to start application ``shvcli``. The first argument is URL specifying where
|
|
82
|
+
client should connect to.
|
|
83
|
+
|
|
84
|
+
After successful connection you will see prompt (``>``) and you can start typing.
|
|
85
|
+
Methods can be called with ``PATH:METHOD`` syntax or with just ``METHOD``. You can use
|
|
86
|
+
``PATH:`` for change current path prefix. This prefix is displayed before prompt and is
|
|
87
|
+
prefixed to any paths you specify on command line. To return to the root you need to use
|
|
88
|
+
absolute path (``/``).
|
|
89
|
+
|
|
90
|
+
An example of usage:
|
|
91
|
+
|
|
92
|
+
.. code-block:: console
|
|
93
|
+
|
|
94
|
+
> ls
|
|
95
|
+
.app
|
|
96
|
+
> dir
|
|
97
|
+
dir ls lschng
|
|
98
|
+
> .app:
|
|
99
|
+
.app> dir
|
|
100
|
+
dir ls lschng shvVersionMajor shvVersionMinor name version ping
|
|
101
|
+
.app> name
|
|
102
|
+
"pyshvbroker"
|
|
103
|
+
.app> broker:ls
|
|
104
|
+
currentClient client clientInfo
|
|
105
|
+
.app> ls broker
|
|
106
|
+
currentClient client clientInfo
|
|
107
|
+
.app> broker/currentClient:info
|
|
108
|
+
{"clientId":0,"mountPoint":null,"subscriptions":[],"userName":"admin"}
|
|
109
|
+
.app> /:
|
|
110
|
+
>
|
|
111
|
+
|
|
112
|
+
.. tip::
|
|
113
|
+
|
|
114
|
+
The validation that is performed by SHVCLI is best effort and sometimes you might
|
|
115
|
+
need to submit call that is considered invalid by SHVCLI. For that reason you can
|
|
116
|
+
use `Ctrl+o` shortcut instead of pressing enter key.
|
|
117
|
+
|
|
118
|
+
********************
|
|
119
|
+
Configuration file
|
|
120
|
+
********************
|
|
121
|
+
|
|
122
|
+
Tool reads configuration from files ``/etc/shvcli.toml`` and ``~/.shvcli.toml``. They
|
|
123
|
+
are in TOML file format and the following sections are supported:
|
|
124
|
+
|
|
125
|
+
**hosts**: That provides mapping from some name to RPC URL.
|
|
126
|
+
|
|
127
|
+
**hosts-shell**: That is same as **hosts** with exception that URL is passed through
|
|
128
|
+
your local Shell to expand any variables or command substitutions.
|
|
129
|
+
|
|
130
|
+
**option**: That allows you to set initial setting for runtime options. The following
|
|
131
|
+
options are available without any plugins:
|
|
132
|
+
|
|
133
|
+
- **vimode**: If Vi input mode should be used for command line input. The default is
|
|
134
|
+
``false``.
|
|
135
|
+
- **autoget**: Automatically call getter methods and print received values when listing
|
|
136
|
+
nodes and methods (``ls`` and ``dir`` methods special handling).
|
|
137
|
+
- **autoprobe**: Completion process benefits from probing of the SHV nodes with ``ls``
|
|
138
|
+
and ``dir``, and to provide easier usage this can happen automatically in background.
|
|
139
|
+
This is what this option controls. It is ``true`` by default but it might not be
|
|
140
|
+
desirable in some cases, because this can generate a lot of hidden traffic.
|
|
141
|
+
- **raw**: Controls if ``ls`` and ``dir`` methods are handled in a special way as
|
|
142
|
+
described later in this document. This special handling can be possibly decremental if
|
|
143
|
+
you are trying to debug something specific with these functions and this provides a
|
|
144
|
+
way to call them with any CPON to see what they provide. Note that caching and
|
|
145
|
+
discovery of the nodes will stop working once you are in the raw mode and thus you
|
|
146
|
+
will no longer get the advantage of that. The default is ``false``.
|
|
147
|
+
- **debug**: Controls if internal debug messages are displayed. These messages can give
|
|
148
|
+
you idea of what shvcli is actually doing behind the wail but it can be also
|
|
149
|
+
overwhelming. The default is ``false``. It is beneficial to disable the **autobrobe**
|
|
150
|
+
once you enable debug because otherwise output on CLI will be mangled on completion.
|
|
151
|
+
- **call_query_timeout**: Timeout in seconds for status request query. The shorter time
|
|
152
|
+
will result in faster request lost detection while very short time will load SHV
|
|
153
|
+
network too much.
|
|
154
|
+
- **call_retry_timeout**: Timeout in seconds when call request is sent again if no
|
|
155
|
+
response is received. This is not applied if query is and thus this mostly is used
|
|
156
|
+
only in case when method doesn't support delayed responses.
|
|
157
|
+
- **autoget_timeout**: Timeout in seconds for call that is part of autoget
|
|
158
|
+
functionality.
|
|
159
|
+
- **history_count**: Integer number used for number of records requested at time for
|
|
160
|
+
``!history`` builtin.
|
|
161
|
+
|
|
162
|
+
Example configuration file:
|
|
163
|
+
|
|
164
|
+
.. code-block:: ini
|
|
165
|
+
|
|
166
|
+
[hosts]
|
|
167
|
+
localhost = tcp://test@localhost?password=test
|
|
168
|
+
|
|
169
|
+
[hosts-shell]
|
|
170
|
+
company = tcp://smith@company.example.org?password=$(pass company/shv)
|
|
171
|
+
|
|
172
|
+
[config]
|
|
173
|
+
vimode = true
|
|
174
|
+
|
|
175
|
+
******************
|
|
176
|
+
Internal methods
|
|
177
|
+
******************
|
|
178
|
+
|
|
179
|
+
CLI provides few additional methods that can be called on top of the ones provided by
|
|
180
|
+
SHV network. They are all prefixed with ``!`` to clearly distinguish them. They provide
|
|
181
|
+
a way to control CLI as well as to get insight into the environment you are running in.
|
|
182
|
+
|
|
183
|
+
**subscribe|sub**: Add new subscribe. Shortcut to the call of
|
|
184
|
+
``.app/broker/currentClient:subscribe`` that accepts arguments in more convenient way.
|
|
185
|
+
The argument can be multiple RPC RIs (``PATH:METHOD:SIGNAL`` patterns).
|
|
186
|
+
|
|
187
|
+
**unsubscribe|usub**: Unsubscribe existing subscription. It is reverse operation to the
|
|
188
|
+
**subscribe** and same remarks apply here as well. It is a shortcut to the call of
|
|
189
|
+
``.app/broker/currentClient:unsubscribe``
|
|
190
|
+
|
|
191
|
+
**subscriptions|subs**: List current subscriptions. This is shortcut to call
|
|
192
|
+
``.app/broker/currentClient:subscriptions``.
|
|
193
|
+
|
|
194
|
+
**cd**: Change current path prefix to given one even when there is no such node.
|
|
195
|
+
|
|
196
|
+
**tree|t**: This prints tree of known nodes from current path prefix. This is not all
|
|
197
|
+
nodes present in the SHV network. This is only what was discovered so far (and cached
|
|
198
|
+
thus it can be also old). You can use it to visualize the tree of nodes you are working
|
|
199
|
+
with as well as to get insight into the state of the cache.
|
|
200
|
+
|
|
201
|
+
**scan[X]**: Perform recursive probing of the tree up to the depth given as `X` (the
|
|
202
|
+
default is 3). On big servers this can be pretty resource demanding and thus use it
|
|
203
|
+
sparely.
|
|
204
|
+
|
|
205
|
+
**set|s**: allows modification of configuration option in runtime. The names are the
|
|
206
|
+
same as in ``config`` section. The boolean options are set if no argument is provided,
|
|
207
|
+
or cleared if name is prefixed with ``no`` (and thus to disable ``raw`` you use
|
|
208
|
+
``noraw``). You can also add ``=true`` or ``=false``. The equal sign is also used with
|
|
209
|
+
integer and floating point options. Without any configuration option it simply prints
|
|
210
|
+
the current configuration.
|
|
211
|
+
|
|
212
|
+
**upload**: provides a way to copy local file to the RPC File node. The parameter must
|
|
213
|
+
be path to the local file to be uploaded.
|
|
214
|
+
|
|
215
|
+
**download**: provides a way to copy RPC File node data to local file. The parameter
|
|
216
|
+
must be path to the local file where data will be stored.
|
|
217
|
+
|
|
218
|
+
**verify**: provides a way to verify RPC File node against local file. The parameter
|
|
219
|
+
must be path to the local file used for the verification.
|
|
220
|
+
|
|
221
|
+
**history**: is helper to list recorded history of signals by ``.history`` API. The
|
|
222
|
+
listing is incremental in ``history_count`` configured number of records and in the
|
|
223
|
+
order from the newest ones.
|
|
224
|
+
|
|
225
|
+
************************************
|
|
226
|
+
Special methods ``ls`` and ``dir``
|
|
227
|
+
************************************
|
|
228
|
+
|
|
229
|
+
These methods are handled in a special way to allow easy discovery of the SHV nodes.
|
|
230
|
+
Their output is processed and displayed in easy to read format but not in the fullest
|
|
231
|
+
content.
|
|
232
|
+
|
|
233
|
+
Their parameter is also handled in a special way. It is considered to be additional path
|
|
234
|
+
suffix unless it is a valid CPON. This is allowed to match the common shells.
|
|
235
|
+
|
|
236
|
+
You can see ``raw`` option to disable this behavior.
|
|
237
|
+
|
|
238
|
+
**************
|
|
239
|
+
OAuth2 login
|
|
240
|
+
**************
|
|
241
|
+
|
|
242
|
+
SHVCLI supports non-standard login method OAuth2. This is not defined by SHV standard.
|
|
243
|
+
The non-standard URL query ``oauth2=y`` is accepted to perform the OAuth2 login. The
|
|
244
|
+
login is facilitated by web browser. SHVCLI will start server on
|
|
245
|
+
``tcp://localhost:37719/`` to be able to receive token.
|
|
246
|
+
|
|
247
|
+
*********
|
|
248
|
+
Plugins
|
|
249
|
+
*********
|
|
250
|
+
|
|
251
|
+
The support for external plugins is provided. These plugins are discovered using Python
|
|
252
|
+
package metadata using the entry point ``shvcli.plugins``.
|
|
253
|
+
|
|
254
|
+
Running tests
|
|
255
|
+
=============
|
|
256
|
+
|
|
257
|
+
This project contains basic tests in directory tests; see the dependencies in the
|
|
258
|
+
``pyproject.toml`` file.
|
|
259
|
+
|
|
260
|
+
To run tests you have to use **pytest**. To run all tests just run it in the top level
|
|
261
|
+
directory of the project:
|
|
262
|
+
|
|
263
|
+
.. code-block:: console
|
|
264
|
+
|
|
265
|
+
$ pytest
|
|
266
|
+
|
|
267
|
+
See the `pytest documentation <https://docs.pytest.org/>`__ for more info.
|
shvcli-0.9.0/README.rst
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#######################################
|
|
2
|
+
Silicon Heaven CLI access application
|
|
3
|
+
#######################################
|
|
4
|
+
|
|
5
|
+
.. image:: https://gitlab.com/silicon-heaven/shvcli/-/raw/master/logo.svg
|
|
6
|
+
:align: right
|
|
7
|
+
:height: 128px
|
|
8
|
+
|
|
9
|
+
This provides an easy to use CLI interfase to access the SHV network.
|
|
10
|
+
|
|
11
|
+
- `📃 Sources <https://gitlab.com/silicon-heaven/shvcli>`__
|
|
12
|
+
- `⁉️ Issue tracker <https://gitlab.com/silicon-heaven/shvcli/-/issues>`__
|
|
13
|
+
- `📕 Silicon Heaven protocol documentation
|
|
14
|
+
<https://silicon-heaven.github.io/shv-doc/>`__
|
|
15
|
+
|
|
16
|
+
**************
|
|
17
|
+
Installation
|
|
18
|
+
**************
|
|
19
|
+
|
|
20
|
+
The installation can be done with package manager ``pip``.
|
|
21
|
+
|
|
22
|
+
.. code-block:: console
|
|
23
|
+
|
|
24
|
+
$ pip install shvcli
|
|
25
|
+
|
|
26
|
+
Documentation
|
|
27
|
+
=============
|
|
28
|
+
|
|
29
|
+
*******
|
|
30
|
+
Usage
|
|
31
|
+
*******
|
|
32
|
+
|
|
33
|
+
You need to start application ``shvcli``. The first argument is URL specifying where
|
|
34
|
+
client should connect to.
|
|
35
|
+
|
|
36
|
+
After successful connection you will see prompt (``>``) and you can start typing.
|
|
37
|
+
Methods can be called with ``PATH:METHOD`` syntax or with just ``METHOD``. You can use
|
|
38
|
+
``PATH:`` for change current path prefix. This prefix is displayed before prompt and is
|
|
39
|
+
prefixed to any paths you specify on command line. To return to the root you need to use
|
|
40
|
+
absolute path (``/``).
|
|
41
|
+
|
|
42
|
+
An example of usage:
|
|
43
|
+
|
|
44
|
+
.. code-block:: console
|
|
45
|
+
|
|
46
|
+
> ls
|
|
47
|
+
.app
|
|
48
|
+
> dir
|
|
49
|
+
dir ls lschng
|
|
50
|
+
> .app:
|
|
51
|
+
.app> dir
|
|
52
|
+
dir ls lschng shvVersionMajor shvVersionMinor name version ping
|
|
53
|
+
.app> name
|
|
54
|
+
"pyshvbroker"
|
|
55
|
+
.app> broker:ls
|
|
56
|
+
currentClient client clientInfo
|
|
57
|
+
.app> ls broker
|
|
58
|
+
currentClient client clientInfo
|
|
59
|
+
.app> broker/currentClient:info
|
|
60
|
+
{"clientId":0,"mountPoint":null,"subscriptions":[],"userName":"admin"}
|
|
61
|
+
.app> /:
|
|
62
|
+
>
|
|
63
|
+
|
|
64
|
+
.. tip::
|
|
65
|
+
|
|
66
|
+
The validation that is performed by SHVCLI is best effort and sometimes you might
|
|
67
|
+
need to submit call that is considered invalid by SHVCLI. For that reason you can
|
|
68
|
+
use `Ctrl+o` shortcut instead of pressing enter key.
|
|
69
|
+
|
|
70
|
+
********************
|
|
71
|
+
Configuration file
|
|
72
|
+
********************
|
|
73
|
+
|
|
74
|
+
Tool reads configuration from files ``/etc/shvcli.toml`` and ``~/.shvcli.toml``. They
|
|
75
|
+
are in TOML file format and the following sections are supported:
|
|
76
|
+
|
|
77
|
+
**hosts**: That provides mapping from some name to RPC URL.
|
|
78
|
+
|
|
79
|
+
**hosts-shell**: That is same as **hosts** with exception that URL is passed through
|
|
80
|
+
your local Shell to expand any variables or command substitutions.
|
|
81
|
+
|
|
82
|
+
**option**: That allows you to set initial setting for runtime options. The following
|
|
83
|
+
options are available without any plugins:
|
|
84
|
+
|
|
85
|
+
- **vimode**: If Vi input mode should be used for command line input. The default is
|
|
86
|
+
``false``.
|
|
87
|
+
- **autoget**: Automatically call getter methods and print received values when listing
|
|
88
|
+
nodes and methods (``ls`` and ``dir`` methods special handling).
|
|
89
|
+
- **autoprobe**: Completion process benefits from probing of the SHV nodes with ``ls``
|
|
90
|
+
and ``dir``, and to provide easier usage this can happen automatically in background.
|
|
91
|
+
This is what this option controls. It is ``true`` by default but it might not be
|
|
92
|
+
desirable in some cases, because this can generate a lot of hidden traffic.
|
|
93
|
+
- **raw**: Controls if ``ls`` and ``dir`` methods are handled in a special way as
|
|
94
|
+
described later in this document. This special handling can be possibly decremental if
|
|
95
|
+
you are trying to debug something specific with these functions and this provides a
|
|
96
|
+
way to call them with any CPON to see what they provide. Note that caching and
|
|
97
|
+
discovery of the nodes will stop working once you are in the raw mode and thus you
|
|
98
|
+
will no longer get the advantage of that. The default is ``false``.
|
|
99
|
+
- **debug**: Controls if internal debug messages are displayed. These messages can give
|
|
100
|
+
you idea of what shvcli is actually doing behind the wail but it can be also
|
|
101
|
+
overwhelming. The default is ``false``. It is beneficial to disable the **autobrobe**
|
|
102
|
+
once you enable debug because otherwise output on CLI will be mangled on completion.
|
|
103
|
+
- **call_query_timeout**: Timeout in seconds for status request query. The shorter time
|
|
104
|
+
will result in faster request lost detection while very short time will load SHV
|
|
105
|
+
network too much.
|
|
106
|
+
- **call_retry_timeout**: Timeout in seconds when call request is sent again if no
|
|
107
|
+
response is received. This is not applied if query is and thus this mostly is used
|
|
108
|
+
only in case when method doesn't support delayed responses.
|
|
109
|
+
- **autoget_timeout**: Timeout in seconds for call that is part of autoget
|
|
110
|
+
functionality.
|
|
111
|
+
- **history_count**: Integer number used for number of records requested at time for
|
|
112
|
+
``!history`` builtin.
|
|
113
|
+
|
|
114
|
+
Example configuration file:
|
|
115
|
+
|
|
116
|
+
.. code-block:: ini
|
|
117
|
+
|
|
118
|
+
[hosts]
|
|
119
|
+
localhost = tcp://test@localhost?password=test
|
|
120
|
+
|
|
121
|
+
[hosts-shell]
|
|
122
|
+
company = tcp://smith@company.example.org?password=$(pass company/shv)
|
|
123
|
+
|
|
124
|
+
[config]
|
|
125
|
+
vimode = true
|
|
126
|
+
|
|
127
|
+
******************
|
|
128
|
+
Internal methods
|
|
129
|
+
******************
|
|
130
|
+
|
|
131
|
+
CLI provides few additional methods that can be called on top of the ones provided by
|
|
132
|
+
SHV network. They are all prefixed with ``!`` to clearly distinguish them. They provide
|
|
133
|
+
a way to control CLI as well as to get insight into the environment you are running in.
|
|
134
|
+
|
|
135
|
+
**subscribe|sub**: Add new subscribe. Shortcut to the call of
|
|
136
|
+
``.app/broker/currentClient:subscribe`` that accepts arguments in more convenient way.
|
|
137
|
+
The argument can be multiple RPC RIs (``PATH:METHOD:SIGNAL`` patterns).
|
|
138
|
+
|
|
139
|
+
**unsubscribe|usub**: Unsubscribe existing subscription. It is reverse operation to the
|
|
140
|
+
**subscribe** and same remarks apply here as well. It is a shortcut to the call of
|
|
141
|
+
``.app/broker/currentClient:unsubscribe``
|
|
142
|
+
|
|
143
|
+
**subscriptions|subs**: List current subscriptions. This is shortcut to call
|
|
144
|
+
``.app/broker/currentClient:subscriptions``.
|
|
145
|
+
|
|
146
|
+
**cd**: Change current path prefix to given one even when there is no such node.
|
|
147
|
+
|
|
148
|
+
**tree|t**: This prints tree of known nodes from current path prefix. This is not all
|
|
149
|
+
nodes present in the SHV network. This is only what was discovered so far (and cached
|
|
150
|
+
thus it can be also old). You can use it to visualize the tree of nodes you are working
|
|
151
|
+
with as well as to get insight into the state of the cache.
|
|
152
|
+
|
|
153
|
+
**scan[X]**: Perform recursive probing of the tree up to the depth given as `X` (the
|
|
154
|
+
default is 3). On big servers this can be pretty resource demanding and thus use it
|
|
155
|
+
sparely.
|
|
156
|
+
|
|
157
|
+
**set|s**: allows modification of configuration option in runtime. The names are the
|
|
158
|
+
same as in ``config`` section. The boolean options are set if no argument is provided,
|
|
159
|
+
or cleared if name is prefixed with ``no`` (and thus to disable ``raw`` you use
|
|
160
|
+
``noraw``). You can also add ``=true`` or ``=false``. The equal sign is also used with
|
|
161
|
+
integer and floating point options. Without any configuration option it simply prints
|
|
162
|
+
the current configuration.
|
|
163
|
+
|
|
164
|
+
**upload**: provides a way to copy local file to the RPC File node. The parameter must
|
|
165
|
+
be path to the local file to be uploaded.
|
|
166
|
+
|
|
167
|
+
**download**: provides a way to copy RPC File node data to local file. The parameter
|
|
168
|
+
must be path to the local file where data will be stored.
|
|
169
|
+
|
|
170
|
+
**verify**: provides a way to verify RPC File node against local file. The parameter
|
|
171
|
+
must be path to the local file used for the verification.
|
|
172
|
+
|
|
173
|
+
**history**: is helper to list recorded history of signals by ``.history`` API. The
|
|
174
|
+
listing is incremental in ``history_count`` configured number of records and in the
|
|
175
|
+
order from the newest ones.
|
|
176
|
+
|
|
177
|
+
************************************
|
|
178
|
+
Special methods ``ls`` and ``dir``
|
|
179
|
+
************************************
|
|
180
|
+
|
|
181
|
+
These methods are handled in a special way to allow easy discovery of the SHV nodes.
|
|
182
|
+
Their output is processed and displayed in easy to read format but not in the fullest
|
|
183
|
+
content.
|
|
184
|
+
|
|
185
|
+
Their parameter is also handled in a special way. It is considered to be additional path
|
|
186
|
+
suffix unless it is a valid CPON. This is allowed to match the common shells.
|
|
187
|
+
|
|
188
|
+
You can see ``raw`` option to disable this behavior.
|
|
189
|
+
|
|
190
|
+
**************
|
|
191
|
+
OAuth2 login
|
|
192
|
+
**************
|
|
193
|
+
|
|
194
|
+
SHVCLI supports non-standard login method OAuth2. This is not defined by SHV standard.
|
|
195
|
+
The non-standard URL query ``oauth2=y`` is accepted to perform the OAuth2 login. The
|
|
196
|
+
login is facilitated by web browser. SHVCLI will start server on
|
|
197
|
+
``tcp://localhost:37719/`` to be able to receive token.
|
|
198
|
+
|
|
199
|
+
*********
|
|
200
|
+
Plugins
|
|
201
|
+
*********
|
|
202
|
+
|
|
203
|
+
The support for external plugins is provided. These plugins are discovered using Python
|
|
204
|
+
package metadata using the entry point ``shvcli.plugins``.
|
|
205
|
+
|
|
206
|
+
Running tests
|
|
207
|
+
=============
|
|
208
|
+
|
|
209
|
+
This project contains basic tests in directory tests; see the dependencies in the
|
|
210
|
+
``pyproject.toml`` file.
|
|
211
|
+
|
|
212
|
+
To run tests you have to use **pytest**. To run all tests just run it in the top level
|
|
213
|
+
directory of the project:
|
|
214
|
+
|
|
215
|
+
.. code-block:: console
|
|
216
|
+
|
|
217
|
+
$ pytest
|
|
218
|
+
|
|
219
|
+
See the `pytest documentation <https://docs.pytest.org/>`__ for more info.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "shvcli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.9.0"
|
|
4
4
|
description = "Silicon Heaven CLI access application"
|
|
5
5
|
readme = "README.rst"
|
|
6
6
|
license = {file = "LICENSE"}
|
|
@@ -16,10 +16,10 @@ classifiers = [
|
|
|
16
16
|
"Topic :: System :: Shells",
|
|
17
17
|
"Topic :: Terminals",
|
|
18
18
|
]
|
|
19
|
-
requires-python = ">=3.
|
|
19
|
+
requires-python = ">=3.12"
|
|
20
20
|
dependencies = [
|
|
21
|
-
"pyshv >= 0.
|
|
22
|
-
"
|
|
21
|
+
"pyshv >= 0.14.0",
|
|
22
|
+
"prompt-toolkit",
|
|
23
23
|
"pygments",
|
|
24
24
|
"pyxdg",
|
|
25
25
|
"more-itertools",
|
|
@@ -28,6 +28,12 @@ dependencies = [
|
|
|
28
28
|
[project.urls]
|
|
29
29
|
repository = "https://gitlab.com/silicon-heaven/shvcli"
|
|
30
30
|
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
test = [
|
|
33
|
+
"pytest",
|
|
34
|
+
"pytest-cov",
|
|
35
|
+
]
|
|
36
|
+
|
|
31
37
|
[project.scripts]
|
|
32
38
|
shvcli = "shvcli.__main__:main"
|
|
33
39
|
|
|
@@ -43,14 +49,13 @@ build_py = "shvcli.__setuptools__.BuildPy"
|
|
|
43
49
|
|
|
44
50
|
[tool.coverage.run]
|
|
45
51
|
branch = true
|
|
52
|
+
omit = ["shvcli/__setuptools__.py", "tests/*"]
|
|
46
53
|
[tool.coverage.report]
|
|
47
54
|
exclude_lines = [
|
|
48
55
|
"pragma: no cover",
|
|
49
56
|
"if typing.TYPE_CHECKING:"
|
|
50
57
|
]
|
|
51
58
|
|
|
52
|
-
[tool.ruff]
|
|
53
|
-
target-version = "py311"
|
|
54
59
|
[tool.ruff.lint]
|
|
55
60
|
select = [
|
|
56
61
|
"F", "E", "W", "I", "N", "D", "UP", "YTT", "ANN", "ASYNC", "ASYNC1", "S", "BLE",
|
|
@@ -59,42 +64,51 @@ select = [
|
|
|
59
64
|
ignore = [
|
|
60
65
|
# Magic methods have defined behavior so what is there to document. __init__
|
|
61
66
|
# should be documented in class docstring.
|
|
62
|
-
"
|
|
67
|
+
"undocumented-magic-method", "undocumented-public-init",
|
|
63
68
|
# These have conflicting rules.
|
|
64
|
-
"
|
|
69
|
+
"incorrect-blank-line-before-class", "multi-line-summary-second-line",
|
|
65
70
|
# Ignore too long lines (format tackles that)
|
|
66
|
-
"
|
|
71
|
+
"line-too-long",
|
|
67
72
|
# It is nice that assert should not be used for input checking but it can be
|
|
68
73
|
# also used for internal consistency checking.
|
|
69
|
-
"
|
|
74
|
+
"assert", "assert-false",
|
|
70
75
|
# subprocess can be insecurely used but not is insecure by design
|
|
71
|
-
"
|
|
76
|
+
"suspicious-subprocess-import", "subprocess-without-shell-equals-true",
|
|
77
|
+
"start-process-with-partial-path",
|
|
72
78
|
# Catching Exception is valid and safe in some cases and thus should be allowed
|
|
73
|
-
"
|
|
79
|
+
"blind-except",
|
|
74
80
|
# Conflict with formatter
|
|
75
|
-
"
|
|
81
|
+
"missing-trailing-comma",
|
|
76
82
|
# Remove too-many limit for more complex code.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
83
|
+
"too-many-public-methods", "too-many-return-statements", "too-many-branches",
|
|
84
|
+
"too-many-arguments", "too-many-positional-arguments",
|
|
85
|
+
"magic-value-comparison", "too-many-nested-blocks",
|
|
79
86
|
# This seems like a wrong rule
|
|
80
|
-
"
|
|
87
|
+
"eq-without-hash",
|
|
81
88
|
]
|
|
82
89
|
preview = true
|
|
83
90
|
[tool.ruff.lint.per-file-ignores]
|
|
84
91
|
"tests/**" = [
|
|
85
|
-
"
|
|
86
|
-
"
|
|
92
|
+
"undocumented-public-module", "undocumented-public-class",
|
|
93
|
+
"undocumented-public-method", "undocumented-public-function",
|
|
94
|
+
"undocumented-public-package", "assert", "hardcoded-password-func-arg",
|
|
95
|
+
"missing-type-function-argument", "missing-type-args",
|
|
96
|
+
"missing-type-kwargs", "missing-return-type-undocumented-public-function",
|
|
97
|
+
"missing-return-type-private-function", "missing-return-type-special-method",
|
|
98
|
+
"missing-return-type-static-method", "no-self-use",
|
|
87
99
|
]
|
|
88
|
-
"docs/conf.py" = ["D100", "D103", "A001", "ANN201", "ANN001"]
|
|
89
100
|
[tool.ruff.format]
|
|
90
101
|
docstring-code-format = true
|
|
91
102
|
preview = true
|
|
92
103
|
|
|
93
104
|
[tool.mypy]
|
|
94
|
-
python_version = "3.
|
|
105
|
+
python_version = "3.12"
|
|
95
106
|
ignore_missing_imports = true
|
|
96
107
|
disallow_untyped_defs = true
|
|
97
108
|
warn_redundant_casts = true
|
|
98
109
|
warn_unused_ignores = true
|
|
99
110
|
warn_return_any = true
|
|
100
111
|
warn_unreachable = true
|
|
112
|
+
[[tool.mypy.overrides]]
|
|
113
|
+
module = "tests.*"
|
|
114
|
+
allow_untyped_defs = true
|
|
@@ -8,7 +8,7 @@ from setuptools.command.build_py import build_py as _build_py
|
|
|
8
8
|
class BuildPy(_build_py):
|
|
9
9
|
"""Custom package build step."""
|
|
10
10
|
|
|
11
|
-
def run(self) -> None: #
|
|
11
|
+
def run(self) -> None: # ruff: ignore[undocumented-public-method]
|
|
12
12
|
package = pathlib.Path(__file__).parent.name
|
|
13
13
|
buildlib = pathlib.Path(self.build_lib) / package
|
|
14
14
|
buildlib.mkdir(parents=True, exist_ok=True)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"""The loader of the version for source file only installation.
|
|
2
2
|
|
|
3
|
-
It looks for pyproject.toml file in upper directory and loads version from
|
|
4
|
-
there.
|
|
3
|
+
It looks for pyproject.toml file in upper directory and loads version from there.
|
|
5
4
|
|
|
6
|
-
This file is overwritten during distribution build to contain only constant
|
|
7
|
-
|
|
5
|
+
This file is overwritten during distribution build to contain only constant VERSION.
|
|
6
|
+
Please see __setuptools__.py for details.
|
|
8
7
|
"""
|
|
9
8
|
|
|
10
9
|
import pathlib
|
|
@@ -12,7 +11,7 @@ import tomllib
|
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
def _get_version() -> str:
|
|
15
|
-
pyproject = pathlib.Path(__file__).
|
|
14
|
+
pyproject = pathlib.Path(__file__).parents[1] / "pyproject.toml"
|
|
16
15
|
if pyproject.exists():
|
|
17
16
|
with pyproject.open("rb") as f:
|
|
18
17
|
res = tomllib.load(f)["project"]["version"]
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
4
|
import collections.abc
|
|
5
|
-
import typing
|
|
6
5
|
|
|
7
6
|
from .args import ArgsParseFuncGenT, register_argparser
|
|
8
7
|
from .client import Client, SHVPath
|
|
@@ -10,7 +9,7 @@ from .cliitems import CliItems
|
|
|
10
9
|
from .scan import scan_nodes
|
|
11
10
|
from .state import StateVar
|
|
12
11
|
|
|
13
|
-
AfterConnT
|
|
12
|
+
type AfterConnT = collections.abc.Callable[
|
|
14
13
|
[Client], collections.abc.Coroutine[None, None, None]
|
|
15
14
|
]
|
|
16
15
|
|