remotivelabs-cli 0.0.15__py3-none-any.whl → 0.0.16__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/export.py CHANGED
@@ -9,7 +9,7 @@ import typer
9
9
 
10
10
  from cli.errors import ErrorPrinter
11
11
 
12
- from .lib.broker import Broker
12
+ from .lib.broker import Broker, SubscribableSignal
13
13
 
14
14
  app = typer.Typer(
15
15
  rich_markup_mode="rich",
@@ -24,8 +24,8 @@ but more formats will come soon
24
24
  def influxdb(
25
25
  url: str = typer.Option(..., help="Broker URL", envvar="REMOTIVE_BROKER_URL"),
26
26
  api_key: str = typer.Option(None, help="Cloud Broker API-KEY", envvar="REMOTIVE_BROKER_API_KEY"),
27
- signal: List[str] = typer.Option(..., help="List of signal names to subscribe to"),
28
- namespace: str = typer.Option(..., help="Cloud Broker API-KEY or access token", envvar="REMOTIVE_BROKER_API_KEY"),
27
+ signal: List[str] = typer.Option(..., help="List of signal names to subscribe to in format namespace:signal_name"),
28
+ # namespace: str = typer.Option(..., help="Cloud Broker API-KEY or access token", envvar="REMOTIVE_BROKER_API_KEY"),
29
29
  on_change_only: bool = typer.Option(default=False, help="Only get signal if value is changed"),
30
30
  output: str = typer.Option(None, help="Write results to file, defaults to stdout"),
31
31
  ):
@@ -37,12 +37,12 @@ def influxdb(
37
37
 
38
38
  Export:
39
39
  remotive broker export influxdb --url [URL] --output signals.influx --namespace VehicleBus \\
40
- --signal Control.SteeringWheel_Position --signal Control.Accelerator_PedalPosition \\
41
- --signal GpsPosition.GPS_Longitude --signal GpsPosition.GPS_Latitude
40
+ --signal vehiclebus:Control.SteeringWheel_Position --signal Control.Accelerator_PedalPosition \\
41
+ --signal vehiclebus:GpsPosition.GPS_Longitude --signal vehiclebus:GpsPosition.GPS_Latitude
42
42
 
43
43
  Output:
44
- Control, SteeringWheel_Position=1.0,Accelerator_PedalPosition=0,Speed=0 1664787032944374000
45
- GpsPosition, GPS_Longitude=12.982076,GPS_Latitude=55.618748 1664787032948256000
44
+ Control, namespace:vehiclebus SteeringWheel_Position=1.0,Accelerator_PedalPosition=0,Speed=0 1664787032944374000
45
+ GpsPosition, namespace:vehiclebus GPS_Longitude=12.982076,GPS_Latitude=55.618748 1664787032948256000
46
46
 
47
47
  Import:
48
48
  influx write --org myorg -b my-bucket -p ns --format=lp -f signals.influx
@@ -62,10 +62,12 @@ def influxdb(
62
62
  signals = list(x)
63
63
  if len(signals) == 0:
64
64
  return
65
-
66
- frame_name = signals[0]["name"].split(".")[0]
67
- signals_str = ",".join(list(map(lambda s: f'{s["name"].split(".")[1]}={s["value"]}', signals)))
68
- influx_lp = f"{frame_name},namespace={namespace} {signals_str} {round(signals[0]['timestamp_us'] * 1000)}"
65
+ sig: str = signals[0]["name"].rpartition(".")[-1]
66
+ frame = signals[0]["name"].rsplit(".", 1)[0]
67
+ # frame_name = signals[0]["name"].split(".")[1]
68
+ namespace = signals[0]["namespace"]
69
+ signals_str = ",".join(list(map(lambda s: f'{sig}={s["value"]}', signals)))
70
+ influx_lp = f"{frame},namespace={namespace} {signals_str} {round(signals[0]['timestamp_us'] * 1000)}"
69
71
  if output is not None:
70
72
  f.write(f"{influx_lp}\n")
71
73
  else:
@@ -104,7 +106,17 @@ def influxdb(
104
106
  # print(namespace)
105
107
  # signals2 = list(map( lambda s: s['signal'], broker.list_signal_names2(namespace)))
106
108
  try:
109
+
110
+ def to_subscribable_signal(sig: str):
111
+ arr = sig.split(":")
112
+ if len(arr) != 2:
113
+ ErrorPrinter.print_hint(f"--signal must have format namespace:signal ({sig})")
114
+ exit(1)
115
+
116
+ return SubscribableSignal(namespace=arr[0], name=arr[1])
117
+
118
+ signals_to_subscribe_to = list(map(to_subscribable_signal, signal))
107
119
  broker = Broker(url, api_key)
108
- broker.subscribe(signal, namespace, per_frame_influx_line_protocol, on_change_only)
120
+ broker.long_name_subscribe(signals_to_subscribe_to, per_frame_influx_line_protocol, on_change_only)
109
121
  except grpc.RpcError as rpc_error:
110
122
  ErrorPrinter.print_grpc_error(rpc_error)
cli/broker/lib/broker.py CHANGED
@@ -484,7 +484,12 @@ class Broker:
484
484
  return subscription
485
485
 
486
486
  def __each_signal(self, signals, callback):
487
- callback(map(lambda s: {"timestamp_us": s.timestamp, "name": s.id.name, "value": self.__get_value(s)}, signals))
487
+ callback(
488
+ map(
489
+ lambda s: {"timestamp_us": s.timestamp, "namespace": s.id.namespace.name, "name": s.id.name, "value": self.__get_value(s)},
490
+ signals,
491
+ )
492
+ )
488
493
 
489
494
  @staticmethod
490
495
  def __get_value(signal):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotivelabs-cli
3
- Version: 0.0.15
3
+ Version: 0.0.16
4
4
  Summary: CLI for operating RemotiveCloud and RemotiveBroker
5
5
  Author: Johan Rask
6
6
  Author-email: johan.rask@remotivelabs.com
@@ -1,10 +1,10 @@
1
1
  cli/__about__.py,sha256=qXVkxWb3aPCF-4MjQhB0wqL2GEblEH4Qwk70o29UkJk,122
2
2
  cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  cli/broker/brokers.py,sha256=sSX--mm5ln5RUFR60VFHQR6NWu4Qz7Jqi2Ws-4TJsDI,3052
4
- cli/broker/export.py,sha256=GxwE9ufWRwfxVh3eTLkwuOqwUOtsvS9Wb7b-BooULC8,3734
4
+ cli/broker/export.py,sha256=kPB8xRe-I-fte5d95E0Uy2wLvQp943e4yFARGPKySoY,4386
5
5
  cli/broker/files.py,sha256=_8elBjbmJ5MEEeFGJ7QYkXzyuLDCDpO6UvEVXHbRy7U,4133
6
6
  cli/broker/lib/__about__.py,sha256=xnZ5V6ZcHW9dhWLWdMzVjYJbEnMKpeXm0_S_mbNzypE,141
7
- cli/broker/lib/broker.py,sha256=b4MO38_SamR2eE-ClDZMWSVpVRfQ6HQ27ALVpmmVGXc,21071
7
+ cli/broker/lib/broker.py,sha256=kpcSaHcjZlcsgNgxwDBEa13RYRtx0Uz-fbBg2pKAHI0,21174
8
8
  cli/broker/playback.py,sha256=oOfC8Jn4Ib-nc9T6ob_uNXZSeCWfft7MrMQPafH4U2I,4846
9
9
  cli/broker/record.py,sha256=gEvo3myHbIl6UyXzhJE741NiwRrFf7doBg6HXzzp5z0,1382
10
10
  cli/broker/scripting.py,sha256=sLDtuktWsVk0fJ3RW4kYyh-_YAVJP3VM0xFIQR499Oo,3392
@@ -33,8 +33,8 @@ cli/tools/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
33
33
  cli/tools/can/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
34
34
  cli/tools/can/can.py,sha256=kSd1c-nxxXyeKkm19oDILiDBZsKOcpjsUT0T3xox5Qs,2172
35
35
  cli/tools/tools.py,sha256=LwQdWMcJ19pCyKUsVfSB2B3R6ui61NxxFWP0Nrnd5Jk,198
36
- remotivelabs_cli-0.0.15.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
37
- remotivelabs_cli-0.0.15.dist-info/METADATA,sha256=6WwZlFqtnnC892J5T6m_Zgs1XGz_wnyNzzihRRFDY_Q,1224
38
- remotivelabs_cli-0.0.15.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
39
- remotivelabs_cli-0.0.15.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
40
- remotivelabs_cli-0.0.15.dist-info/RECORD,,
36
+ remotivelabs_cli-0.0.16.dist-info/LICENSE,sha256=qDPP_yfuv1fF-u7EfexN-cN3M8aFgGVndGhGLovLKz0,608
37
+ remotivelabs_cli-0.0.16.dist-info/METADATA,sha256=A5ZA5VGXfw287Q187R5Pt4cPH5xOVmDWzeRq8offtPk,1224
38
+ remotivelabs_cli-0.0.16.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
39
+ remotivelabs_cli-0.0.16.dist-info/entry_points.txt,sha256=lvDhPgagLqW_KTnLPCwKSqfYlEp-1uYVosRiPjsVj10,45
40
+ remotivelabs_cli-0.0.16.dist-info/RECORD,,