remotivelabs-cli 0.0.35__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 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(None, help="Signal names to subscribe to, mandatory when not using script"),
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 include at least one signal and one namespace or use script when subscribing")
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/cloud/configs.py CHANGED
@@ -59,6 +59,17 @@ def upload(
59
59
  )
60
60
 
61
61
 
62
+ @app.command()
63
+ def describe(
64
+ signal_db_file: str = typer.Argument("", help="Signal database file"),
65
+ project: str = typer.Option(..., help="Project ID", envvar="REMOTIVE_CLOUD_PROJECT"),
66
+ ) -> None:
67
+ """
68
+ Shows all metadata related to this signal database
69
+ """
70
+ Rest.handle_get(f"/api/project/{project}/files/config/{signal_db_file}")
71
+
72
+
62
73
  @app.command()
63
74
  def download(
64
75
  signal_db_file: str = typer.Argument("", help="Signal database file"),
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotivelabs-cli
3
- Version: 0.0.35
3
+ Version: 0.0.37
4
4
  Summary: CLI for operating RemotiveCloud and RemotiveBroker
5
5
  Author: Johan Rask
6
6
  Author-email: johan.rask@remotivelabs.com
@@ -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=_GwgXkILcw5pYhvWEUKotnMztbfSRKTNXAhx1aVv-8s,24523
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=KflNaVFgsKFi1suec7fSkCfGhcJ0LfPTMRGVQUlsU-0,7058
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
@@ -17,7 +17,7 @@ cli/cloud/auth/login.py,sha256=Yrir9ThKJ7sqL4AsEivXxMKjP7QevEGxcm3f2BPUqFg,1898
17
17
  cli/cloud/auth_tokens.py,sha256=MGTM8gMqKbCBVZudH1cfhRqJRfsiStUZXNhPcrs9-7I,1216
18
18
  cli/cloud/brokers.py,sha256=DNj79MTkPylKUQbr-iPUhQgfNJLAW8UehnvgpEmNH_k,3890
19
19
  cli/cloud/cloud_cli.py,sha256=c_JMjAOsJnAw4TM7gkPWmEfrrQly6lAppvfHAmaUGmo,1262
20
- cli/cloud/configs.py,sha256=bZzZF-yNkZkfJK5baU0Xh_vQRrJkmuzEv8xx4_IkXZ8,4714
20
+ cli/cloud/configs.py,sha256=0GDr2-N77Aj7DG26zjamA0zpV3iMyVYhtoTak-n8BUc,5069
21
21
  cli/cloud/organisations.py,sha256=txKQmSQEpTmeqlqngai8pwgQQEvRgeDd0dT_VzZ7RNc,752
22
22
  cli/cloud/projects.py,sha256=YrwPJClC2Sq_y1HjPd_tzaiv4GEnnsXSXHBhtQCPdK0,1431
23
23
  cli/cloud/recordings.py,sha256=XKLHTkOdcfEbXyNX4G_TbqVkO4aazoAwL79KoYDz9RY,25020
@@ -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=CXYArw1W82bRFwJkJ3tD-Ek1huKeah502DGMvPxHYFo,1366
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.35.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
50
- remotivelabs_cli-0.0.35.dist-info/METADATA,sha256=FfNWEMkPJEaFaxOVfi_WCpEBu7Anu7VUieT-uGZGQO4,1359
51
- remotivelabs_cli-0.0.35.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
52
- remotivelabs_cli-0.0.35.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
53
- remotivelabs_cli-0.0.35.dist-info/RECORD,,
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,,