shvcli 0.6.0__tar.gz → 0.6.1__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.6.0/shvcli.egg-info → shvcli-0.6.1}/PKG-INFO +7 -1
- {shvcli-0.6.0 → shvcli-0.6.1}/README.rst +6 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/pyproject.toml +1 -1
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/cli.py +7 -1
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/config.py +25 -5
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/lsdir.py +12 -4
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/parse.py +1 -1
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/tools.py +1 -1
- {shvcli-0.6.0 → shvcli-0.6.1/shvcli.egg-info}/PKG-INFO +7 -1
- {shvcli-0.6.0 → shvcli-0.6.1}/LICENSE +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/setup.cfg +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/__init__.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/__main__.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/__version__.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/builtin.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/builtin_impl.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/client.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/complet.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/complet_tools.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/py.typed +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/scan.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/valid.py +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli/version +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli.egg-info/SOURCES.txt +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli.egg-info/dependency_links.txt +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli.egg-info/entry_points.txt +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli.egg-info/requires.txt +0 -0
- {shvcli-0.6.0 → shvcli-0.6.1}/shvcli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shvcli
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Silicon Heaven CLI access application
|
|
5
5
|
Author: Elektroline a.s.
|
|
6
6
|
License: MIT License
|
|
@@ -140,6 +140,12 @@ switched in runtime. The following options are available:
|
|
|
140
140
|
* **cache**: Controls if cache is preserved between invocations. Cache is
|
|
141
141
|
separated based on the connection URL and stored in files in
|
|
142
142
|
``$XDG_CACHE_HOME/shvcli``. The default is ``true``.
|
|
143
|
+
* **call_attempts**: Number of attempts before method call is abandoned and
|
|
144
|
+
timeout is reported. This makes the total time multiple of **call_timeout**.
|
|
145
|
+
* **call_timeout**: Timeout in seconds before call attempt is abandoned. Based
|
|
146
|
+
on the **call_attempts** call is attempted again or timeout is reported.
|
|
147
|
+
* **autoget_timeout**: Timeout in seconds before call that is part of autoget
|
|
148
|
+
functionality.
|
|
143
149
|
|
|
144
150
|
|
|
145
151
|
Example configuration file:
|
|
@@ -95,6 +95,12 @@ switched in runtime. The following options are available:
|
|
|
95
95
|
* **cache**: Controls if cache is preserved between invocations. Cache is
|
|
96
96
|
separated based on the connection URL and stored in files in
|
|
97
97
|
``$XDG_CACHE_HOME/shvcli``. The default is ``true``.
|
|
98
|
+
* **call_attempts**: Number of attempts before method call is abandoned and
|
|
99
|
+
timeout is reported. This makes the total time multiple of **call_timeout**.
|
|
100
|
+
* **call_timeout**: Timeout in seconds before call attempt is abandoned. Based
|
|
101
|
+
on the **call_attempts** call is attempted again or timeout is reported.
|
|
102
|
+
* **autoget_timeout**: Timeout in seconds before call that is part of autoget
|
|
103
|
+
functionality.
|
|
98
104
|
|
|
99
105
|
|
|
100
106
|
Example configuration file:
|
|
@@ -117,9 +117,15 @@ async def handle_line(shvclient: SHVClient, config: CliConfig, cmdline: str) ->
|
|
|
117
117
|
else:
|
|
118
118
|
print_cpon(
|
|
119
119
|
await shvclient.call(
|
|
120
|
-
config.shvpath(items.path),
|
|
120
|
+
config.shvpath(items.path),
|
|
121
|
+
items.method,
|
|
122
|
+
param,
|
|
123
|
+
call_attempts=config.call_attempts,
|
|
124
|
+
call_timeout=config.call_timeout,
|
|
121
125
|
)
|
|
122
126
|
)
|
|
127
|
+
except TimeoutError:
|
|
128
|
+
print("Call timed out.")
|
|
123
129
|
except RpcError as exc:
|
|
124
130
|
print(f"{type(exc).__name__}: {exc.message}")
|
|
125
131
|
else:
|
|
@@ -4,6 +4,7 @@ import collections.abc
|
|
|
4
4
|
import configparser
|
|
5
5
|
import enum
|
|
6
6
|
import functools
|
|
7
|
+
import itertools
|
|
7
8
|
import logging
|
|
8
9
|
import pathlib
|
|
9
10
|
import subprocess
|
|
@@ -20,6 +21,7 @@ class CliConfig:
|
|
|
20
21
|
|
|
21
22
|
BOOL = enum.auto()
|
|
22
23
|
INT = enum.auto()
|
|
24
|
+
FLOAT = enum.auto()
|
|
23
25
|
|
|
24
26
|
OPTS: collections.abc.Mapping[str, Type] = {
|
|
25
27
|
"vimode": Type.BOOL,
|
|
@@ -27,12 +29,21 @@ class CliConfig:
|
|
|
27
29
|
"autoprobe": Type.BOOL,
|
|
28
30
|
"raw": Type.BOOL,
|
|
29
31
|
"debug": Type.BOOL,
|
|
32
|
+
"call_attempts": Type.INT,
|
|
33
|
+
"call_timeout": Type.FLOAT,
|
|
34
|
+
"autoget_timeout": Type.FLOAT,
|
|
30
35
|
}
|
|
31
|
-
"""
|
|
36
|
+
"""Options allowed to be set in runtime and from configuration file.
|
|
37
|
+
|
|
32
38
|
You can use :func:`setattr` and :func:`getattr`.
|
|
33
39
|
"""
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
COPTS: collections.abc.Mapping[str, Type] = {
|
|
42
|
+
"cache": Type.BOOL,
|
|
43
|
+
}
|
|
44
|
+
"""Options allowed to be set only from configuration file."""
|
|
45
|
+
|
|
46
|
+
def __init__(self) -> None: # noqa: PLR0915
|
|
36
47
|
"""Initialize the configuration to the default and load config files."""
|
|
37
48
|
self.hosts: dict[str, RpcUrl] = {}
|
|
38
49
|
"""Hosts that can be used instead of URL."""
|
|
@@ -53,6 +64,13 @@ class CliConfig:
|
|
|
53
64
|
"""Interpret ls and dir method calls internally or not."""
|
|
54
65
|
self.cache: bool = True
|
|
55
66
|
"""Preserve cache between executions. Not modifiable in runtime!"""
|
|
67
|
+
self.call_attempts: int = 1
|
|
68
|
+
"""Number of call attempts before call is abandoned."""
|
|
69
|
+
self.call_timeout: float = 5.0
|
|
70
|
+
"""Timeout in seconds before call is abandoned."""
|
|
71
|
+
self.autoget_timeout: float = 1.0
|
|
72
|
+
"""Timeout in seconds for call that is part of autoget feature."""
|
|
73
|
+
|
|
56
74
|
self.initial_scan: bool = False
|
|
57
75
|
"""Perform scan right after connection."""
|
|
58
76
|
self.initial_scan_depth: int = 3
|
|
@@ -74,17 +92,19 @@ class CliConfig:
|
|
|
74
92
|
if self.hosts_shell and self.__url is None:
|
|
75
93
|
self.__url = self.hosts_shell[next(iter(self.hosts_shell))]
|
|
76
94
|
case "config":
|
|
77
|
-
for n, t in self.OPTS.items():
|
|
95
|
+
for n, t in itertools.chain(self.OPTS.items(), self.COPTS.items()):
|
|
78
96
|
value = getattr(self, n)
|
|
79
97
|
match t:
|
|
80
98
|
case self.Type.BOOL:
|
|
81
99
|
value = sec.getboolean(n, fallback=value)
|
|
82
100
|
case self.Type.INT:
|
|
83
|
-
value = sec.
|
|
101
|
+
value = sec.getint(n, fallback=value)
|
|
102
|
+
case self.Type.FLOAT:
|
|
103
|
+
value = sec.getfloat(n, fallback=value)
|
|
84
104
|
case _:
|
|
85
105
|
raise NotImplementedError(f"Unhandled type: {t!r}")
|
|
86
106
|
setattr(self, n, value)
|
|
87
|
-
if opts := set(sec.keys()) - set(self.OPTS.
|
|
107
|
+
if opts := set(sec.keys()) - set(self.OPTS) - set(self.COPTS):
|
|
88
108
|
raise ValueError(
|
|
89
109
|
f"Invalid configuration option: {', '.join(opts)}"
|
|
90
110
|
)
|
|
@@ -85,9 +85,12 @@ async def ls_method(shvclient: SHVClient, config: CliConfig, items: CliItems) ->
|
|
|
85
85
|
if "get" in nv.methods:
|
|
86
86
|
try:
|
|
87
87
|
resp = await shvclient.call(
|
|
88
|
-
str(pathlib.PurePosixPath(shvpath) / nn),
|
|
88
|
+
str(pathlib.PurePosixPath(shvpath) / nn),
|
|
89
|
+
"get",
|
|
90
|
+
call_attempts=1,
|
|
91
|
+
call_timeout=config.autoget_timeout,
|
|
89
92
|
)
|
|
90
|
-
except RpcError:
|
|
93
|
+
except (RpcError, TimeoutError):
|
|
91
94
|
pass
|
|
92
95
|
else:
|
|
93
96
|
print_row(
|
|
@@ -113,8 +116,13 @@ async def dir_method(shvclient: SHVClient, config: CliConfig, items: CliItems) -
|
|
|
113
116
|
n = [("", " " * (w - len(d.name))), dir_method_format(d)]
|
|
114
117
|
if _use_autoget(d):
|
|
115
118
|
try:
|
|
116
|
-
resp = await shvclient.call(
|
|
117
|
-
|
|
119
|
+
resp = await shvclient.call(
|
|
120
|
+
shvpath,
|
|
121
|
+
d.name,
|
|
122
|
+
call_attempts=1,
|
|
123
|
+
call_timeout=config.autoget_timeout,
|
|
124
|
+
)
|
|
125
|
+
except (RpcError, TimeoutError):
|
|
118
126
|
pass
|
|
119
127
|
else:
|
|
120
128
|
print_row(
|
|
@@ -59,7 +59,7 @@ class CliItems:
|
|
|
59
59
|
path = parts[0] if parts[0] else "**"
|
|
60
60
|
method = parts[1] if len(parts) == 2 else "*"
|
|
61
61
|
signal = parts[2] if len(parts) == 3 else "*"
|
|
62
|
-
res.append(f"{self.path}{
|
|
62
|
+
res.append(f"{self.path}{'/' if self.path else ''}{path}:{method}:{signal}")
|
|
63
63
|
return res
|
|
64
64
|
|
|
65
65
|
def interpret_param_set(self) -> tuple[str | None, str | None]:
|
|
@@ -141,7 +141,7 @@ def print_cpon(data: shv.SHVType, prefix: str = "", short: bool = False) -> None
|
|
|
141
141
|
cpon = "\n".join(_wrap_cpon(prefix + shv.Cpon.pack(data)))[len(prefix) :]
|
|
142
142
|
print_ftext(itertools.chain(iter((("", prefix),)), cpon_ftext(cpon)))
|
|
143
143
|
else:
|
|
144
|
-
|
|
144
|
+
print_ftext(
|
|
145
145
|
itertools.chain(
|
|
146
146
|
iter((("", prefix),)),
|
|
147
147
|
cpon_ftext(shv.Cpon.pack(data, shv.CponWriter.Options(indent=b" "))),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shvcli
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Silicon Heaven CLI access application
|
|
5
5
|
Author: Elektroline a.s.
|
|
6
6
|
License: MIT License
|
|
@@ -140,6 +140,12 @@ switched in runtime. The following options are available:
|
|
|
140
140
|
* **cache**: Controls if cache is preserved between invocations. Cache is
|
|
141
141
|
separated based on the connection URL and stored in files in
|
|
142
142
|
``$XDG_CACHE_HOME/shvcli``. The default is ``true``.
|
|
143
|
+
* **call_attempts**: Number of attempts before method call is abandoned and
|
|
144
|
+
timeout is reported. This makes the total time multiple of **call_timeout**.
|
|
145
|
+
* **call_timeout**: Timeout in seconds before call attempt is abandoned. Based
|
|
146
|
+
on the **call_attempts** call is attempted again or timeout is reported.
|
|
147
|
+
* **autoget_timeout**: Timeout in seconds before call that is part of autoget
|
|
148
|
+
functionality.
|
|
143
149
|
|
|
144
150
|
|
|
145
151
|
Example configuration file:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|