remotivelabs-cli 0.0.36__py3-none-any.whl → 0.0.37__py3-none-any.whl
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.
- cli/broker/lib/broker.py +8 -0
- cli/broker/signals.py +29 -2
- cli/errors.py +2 -0
- {remotivelabs_cli-0.0.36.dist-info → remotivelabs_cli-0.0.37.dist-info}/METADATA +1 -1
- {remotivelabs_cli-0.0.36.dist-info → remotivelabs_cli-0.0.37.dist-info}/RECORD +8 -8
- {remotivelabs_cli-0.0.36.dist-info → remotivelabs_cli-0.0.37.dist-info}/LICENSE +0 -0
- {remotivelabs_cli-0.0.36.dist-info → remotivelabs_cli-0.0.37.dist-info}/WHEEL +0 -0
- {remotivelabs_cli-0.0.36.dist-info → remotivelabs_cli-0.0.37.dist-info}/entry_points.txt +0 -0
cli/broker/lib/broker.py
CHANGED
@@ -14,6 +14,7 @@ from threading import Thread
|
|
14
14
|
from typing import Any, Callable, Dict, Iterable, List, Sequence, Union
|
15
15
|
|
16
16
|
import grpc
|
17
|
+
import remotivelabs.broker.generated.sync.network_api_pb2 as network_api
|
17
18
|
import remotivelabs.broker.generated.sync.traffic_api_pb2 as traffic_api
|
18
19
|
import remotivelabs.broker.sync as br
|
19
20
|
import remotivelabs.broker.sync.helper as br_helper
|
@@ -220,6 +221,13 @@ class Broker:
|
|
220
221
|
self.play(recording_and_namespace)
|
221
222
|
callback(offset_length, total_length, get_mode(mode))
|
222
223
|
|
224
|
+
def listen_on_frame_distribution(self, namespace: str, callback: Callable[[Dict[str, Any]], None]) -> None:
|
225
|
+
config = network_api.FramesDistributionConfig(namespace=br.common_pb2.NameSpace(name=namespace))
|
226
|
+
frame_distribution_stream = self.network_stub.SubscribeToFramesDistribution(config)
|
227
|
+
for frame in frame_distribution_stream:
|
228
|
+
f = MessageToDict(frame, including_default_value_fields=True, preserving_proto_field_name=True)
|
229
|
+
callback(f)
|
230
|
+
|
223
231
|
def pause(self, namespace: str, path: str, silent: bool = False) -> br.traffic_api_pb2.PlaybackInfos:
|
224
232
|
playback_list = [
|
225
233
|
{
|
cli/broker/signals.py
CHANGED
@@ -4,6 +4,7 @@ import json
|
|
4
4
|
import numbers
|
5
5
|
import os
|
6
6
|
import signal as os_signal
|
7
|
+
from datetime import datetime
|
7
8
|
from pathlib import Path
|
8
9
|
from typing import Any, Dict, Iterable, List, TypedDict, Union
|
9
10
|
|
@@ -64,7 +65,7 @@ def read_scripted_code_file(file_path: Path) -> bytes:
|
|
64
65
|
def subscribe( # noqa: C901
|
65
66
|
url: str = typer.Option(..., help="Broker URL", envvar="REMOTIVE_BROKER_URL"),
|
66
67
|
api_key: str = typer.Option(None, help="Cloud Broker API-KEY or access token", envvar="REMOTIVE_BROKER_API_KEY"),
|
67
|
-
signal: List[str] = typer.Option(
|
68
|
+
signal: List[str] = typer.Option([], help="Signal names to subscribe to, mandatory when not using script"),
|
68
69
|
script: Path = typer.Option(
|
69
70
|
None,
|
70
71
|
exists=True,
|
@@ -96,7 +97,7 @@ def subscribe( # noqa: C901
|
|
96
97
|
|
97
98
|
if script is None:
|
98
99
|
if len(signal) == 0:
|
99
|
-
ErrorPrinter.print_generic_error("You must use
|
100
|
+
ErrorPrinter.print_generic_error("You must use --signal or use --script when subscribing")
|
100
101
|
exit(1)
|
101
102
|
|
102
103
|
if script is not None:
|
@@ -194,3 +195,29 @@ def namespaces(
|
|
194
195
|
print(json.dumps(namespaces_json))
|
195
196
|
except grpc.RpcError as rpc_error:
|
196
197
|
ErrorPrinter.print_grpc_error(rpc_error)
|
198
|
+
|
199
|
+
|
200
|
+
@app.command()
|
201
|
+
def frame_distribution(
|
202
|
+
url: str = typer.Option(..., help="Broker URL", envvar="REMOTIVE_BROKER_URL"),
|
203
|
+
api_key: str = typer.Option(None, help="Cloud Broker API-KEY or access token", envvar="REMOTIVE_BROKER_API_KEY"),
|
204
|
+
namespace: str = typer.Option(..., help="Namespace"),
|
205
|
+
) -> None:
|
206
|
+
"""
|
207
|
+
Use this command to get frames currently available on the specified namespace.
|
208
|
+
"""
|
209
|
+
try:
|
210
|
+
broker = Broker(url, api_key)
|
211
|
+
|
212
|
+
def on_data(data: Dict[str, Any]) -> None:
|
213
|
+
timestamp: str = datetime.now().strftime("%H:%M:%S")
|
214
|
+
distribution = data["countsByFrameId"]
|
215
|
+
if len(distribution) == 0:
|
216
|
+
ErrorPrinter.print_hint(f"{timestamp} - No frames available")
|
217
|
+
else:
|
218
|
+
for d in distribution:
|
219
|
+
ErrorPrinter.print_generic_message(f"{timestamp}: {d}")
|
220
|
+
|
221
|
+
broker.listen_on_frame_distribution(namespace, on_data)
|
222
|
+
except grpc.RpcError as rpc_error:
|
223
|
+
ErrorPrinter.print_grpc_error(rpc_error)
|
cli/errors.py
CHANGED
@@ -7,6 +7,8 @@ from rich.console import Console
|
|
7
7
|
err_console = Console(stderr=True)
|
8
8
|
|
9
9
|
|
10
|
+
# This should be renamed to Printer since print_generic_message is not an error message.
|
11
|
+
# Then we can also add more things here
|
10
12
|
class ErrorPrinter:
|
11
13
|
@staticmethod
|
12
14
|
def print_grpc_error(error: grpc.RpcError) -> None:
|
@@ -3,13 +3,13 @@ cli/broker/brokers.py,sha256=oUadEL6xQ4bhXucBH-ZjL67VuERf19kn1g240v_lEpg,3197
|
|
3
3
|
cli/broker/export.py,sha256=3sG9i6ZwOQW6snu87NSzOL2_giQTYQMzQlpPg7z8n78,4431
|
4
4
|
cli/broker/files.py,sha256=_MVwitQ5Z9-lNDb3biXqnlkKti8rizTEw0nnAViussU,4181
|
5
5
|
cli/broker/lib/__about__.py,sha256=xnZ5V6ZcHW9dhWLWdMzVjYJbEnMKpeXm0_S_mbNzypE,141
|
6
|
-
cli/broker/lib/broker.py,sha256=
|
6
|
+
cli/broker/lib/broker.py,sha256=HbGo83j6ipaol0uJ93Me78pOPjy7p8PUjYT9xZmRT-w,25086
|
7
7
|
cli/broker/license_flows.py,sha256=qJplaeugkUiypFGPdEIl5Asqlf7W3geJ-wU-QbYMP_8,7216
|
8
8
|
cli/broker/licenses.py,sha256=Ddl243re8RoeP9CoWWbIzwDePQ9l8r7ixmbd1gqn8f0,3973
|
9
9
|
cli/broker/playback.py,sha256=hdDKXGPuIE3gcT-kgQltgn5jsPzK19Yh9hiNcgtkLX0,3992
|
10
10
|
cli/broker/record.py,sha256=Oa6hUpS0Dgnt0f6Ig33vl0Jy8wN7wMXfemaxXWjRVoQ,1414
|
11
11
|
cli/broker/scripting.py,sha256=8577_C6siOk90s4G1ItIfAoFIUAkS0ItUl5kqR0cD-k,3792
|
12
|
-
cli/broker/signals.py,sha256=
|
12
|
+
cli/broker/signals.py,sha256=BHNWH9o1msPJQgw7bplg7W1JNtB4Us_abQp5H8Y3pRY,8079
|
13
13
|
cli/cloud/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
cli/cloud/auth/__init__.py,sha256=MtQ01-n8CgZb9Y_SvxwZUgj44Yo0dFAU3_XwhQiUYtw,54
|
15
15
|
cli/cloud/auth/cmd.py,sha256=Lew9gJDC4pU2Hvbrbe4ZPoanphN0CiNwbpLAo9R00gM,1622
|
@@ -35,7 +35,7 @@ cli/cloud/uri.py,sha256=QZCus--KJQlVwGCOzZqiglvj8VvSRKxfVvN33Pilgyg,3616
|
|
35
35
|
cli/connect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
36
|
cli/connect/connect.py,sha256=U--6dtHxUlvE81J37rABFez4TbF7AXWOpZYZnL7sPMY,3994
|
37
37
|
cli/connect/protopie/protopie.py,sha256=xEfCgoW4p0vlWnSBvgBeDN9QSlyKcOcHfa6EyeAyVoM,6364
|
38
|
-
cli/errors.py,sha256=
|
38
|
+
cli/errors.py,sha256=8_BcTPX3mrPFDQJKKBg6ERjs6HSOiewrY86K1Jays74,1495
|
39
39
|
cli/remotive.py,sha256=rwCIPFuWn0CNxLU2Sgwug5UVjletC1DTJrxUtGkVGPs,1907
|
40
40
|
cli/settings/__init__.py,sha256=4Mj9DFvRBN0LKn6PPLrb-BmuObP707IYeRmg7t7aycg,288
|
41
41
|
cli/settings/cmd.py,sha256=sj1bYgMXUAcS4sx_dZjPVCEjoVAR1p_H-KYb7w02wvU,1992
|
@@ -46,8 +46,8 @@ cli/tools/can/RemotiveLabs.can1.log,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
46
46
|
cli/tools/can/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
47
|
cli/tools/can/can.py,sha256=8uATViSFlpkdSiIm4fzbuQi1_m7V9Pym-K17TaJQRHU,2262
|
48
48
|
cli/tools/tools.py,sha256=0KU-hXR1f9xHP4BOG9A9eXfmICLmNuQCOU8ueF6iGg0,198
|
49
|
-
remotivelabs_cli-0.0.
|
50
|
-
remotivelabs_cli-0.0.
|
51
|
-
remotivelabs_cli-0.0.
|
52
|
-
remotivelabs_cli-0.0.
|
53
|
-
remotivelabs_cli-0.0.
|
49
|
+
remotivelabs_cli-0.0.37.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
|
50
|
+
remotivelabs_cli-0.0.37.dist-info/METADATA,sha256=kigJThZ9liO7Qm3yg2u5mw8WPQyx9mb-aFiEbVeeb4Y,1359
|
51
|
+
remotivelabs_cli-0.0.37.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
52
|
+
remotivelabs_cli-0.0.37.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
|
53
|
+
remotivelabs_cli-0.0.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|