remotivelabs-cli 0.2.3__py3-none-any.whl → 0.3.1__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.
Potentially problematic release.
This version of remotivelabs-cli might be problematic. Click here for more details.
- cli/broker/__init__.py +36 -0
- cli/broker/discovery.py +43 -0
- cli/broker/export.py +6 -36
- cli/broker/files.py +12 -12
- cli/broker/lib/broker.py +132 -106
- cli/broker/lib/client.py +224 -0
- cli/broker/lib/helper.py +277 -0
- cli/broker/lib/signalcreator.py +196 -0
- cli/broker/license_flows.py +11 -13
- cli/broker/playback.py +10 -10
- cli/broker/record.py +4 -4
- cli/broker/scripting.py +6 -9
- cli/broker/signals.py +17 -19
- cli/cloud/__init__.py +17 -0
- cli/cloud/auth/cmd.py +74 -33
- cli/cloud/auth/login.py +42 -54
- cli/cloud/auth_tokens.py +40 -247
- cli/cloud/brokers.py +5 -9
- cli/cloud/configs.py +4 -17
- cli/cloud/licenses/__init__.py +0 -0
- cli/cloud/licenses/cmd.py +14 -0
- cli/cloud/organisations.py +12 -17
- cli/cloud/projects.py +3 -3
- cli/cloud/recordings.py +35 -61
- cli/cloud/recordings_playback.py +22 -22
- cli/cloud/resumable_upload.py +6 -6
- cli/cloud/service_account_tokens.py +4 -3
- cli/cloud/storage/cmd.py +2 -3
- cli/cloud/storage/copy.py +2 -1
- cli/connect/connect.py +4 -4
- cli/connect/protopie/protopie.py +22 -30
- cli/remotive.py +16 -26
- cli/settings/__init__.py +1 -2
- cli/settings/config_file.py +2 -0
- cli/settings/core.py +146 -146
- cli/settings/migration/migrate_config_file.py +13 -6
- cli/settings/migration/migration_tools.py +6 -4
- cli/settings/state_file.py +12 -4
- cli/tools/can/can.py +4 -7
- cli/topology/__init__.py +3 -0
- cli/topology/cmd.py +60 -83
- cli/topology/start_trial.py +105 -0
- cli/typer/typer_utils.py +3 -6
- cli/utils/console.py +61 -0
- cli/utils/rest_helper.py +33 -31
- cli/utils/versions.py +7 -19
- {remotivelabs_cli-0.2.3.dist-info → remotivelabs_cli-0.3.1.dist-info}/METADATA +3 -2
- remotivelabs_cli-0.3.1.dist-info/RECORD +74 -0
- cli/broker/brokers.py +0 -93
- cli/cloud/cloud_cli.py +0 -29
- cli/errors.py +0 -44
- remotivelabs_cli-0.2.3.dist-info/RECORD +0 -67
- {remotivelabs_cli-0.2.3.dist-info → remotivelabs_cli-0.3.1.dist-info}/LICENSE +0 -0
- {remotivelabs_cli-0.2.3.dist-info → remotivelabs_cli-0.3.1.dist-info}/WHEEL +0 -0
- {remotivelabs_cli-0.2.3.dist-info → remotivelabs_cli-0.3.1.dist-info}/entry_points.txt +0 -0
cli/connect/protopie/protopie.py
CHANGED
|
@@ -5,27 +5,22 @@ import json
|
|
|
5
5
|
import os
|
|
6
6
|
import sys
|
|
7
7
|
import time
|
|
8
|
-
import traceback
|
|
9
8
|
from pathlib import Path
|
|
10
9
|
from typing import Any, Dict, List, Tuple, Union
|
|
11
10
|
|
|
12
11
|
import grpc
|
|
13
12
|
import socketio
|
|
14
|
-
from remotivelabs.broker.sync import BrokerException, Client, SignalIdentifier, SignalsInFrame
|
|
15
|
-
from rich import print as pretty_print
|
|
16
|
-
from rich.console import Console
|
|
17
13
|
from socketio.exceptions import ConnectionError as SocketIoConnectionError
|
|
18
14
|
|
|
19
15
|
from cli.broker.lib.broker import SubscribableSignal
|
|
20
|
-
from cli.
|
|
16
|
+
from cli.broker.lib.client import BrokerException, Client, SignalIdentifier, SignalsInFrame
|
|
21
17
|
from cli.settings import settings
|
|
18
|
+
from cli.utils.console import print_generic_error, print_generic_message, print_success, print_unformatted_to_stderr
|
|
22
19
|
|
|
23
20
|
PP_CONNECT_APP_NAME = "RemotiveBridge"
|
|
24
21
|
|
|
25
22
|
io = socketio.Client()
|
|
26
23
|
|
|
27
|
-
err_console = Console(stderr=True)
|
|
28
|
-
|
|
29
24
|
_has_received_signal = False
|
|
30
25
|
is_connected = False
|
|
31
26
|
config_path: Path
|
|
@@ -35,7 +30,7 @@ broker: Any
|
|
|
35
30
|
|
|
36
31
|
@io.on("connect")
|
|
37
32
|
def on_connect() -> None:
|
|
38
|
-
|
|
33
|
+
print_success("Connected to ProtoPie Connect")
|
|
39
34
|
io.emit("ppBridgeApp", {"name": PP_CONNECT_APP_NAME})
|
|
40
35
|
io.emit("PLUGIN_STARTED", {"name": PP_CONNECT_APP_NAME})
|
|
41
36
|
|
|
@@ -72,8 +67,8 @@ def get_signal_name(expression: str, s_name: str) -> str:
|
|
|
72
67
|
sig_name = eval(f"s_name.{expression}")
|
|
73
68
|
return str(sig_name)
|
|
74
69
|
except Exception as e:
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
print_generic_error(f"Failed to evaluate your python expression {expression}")
|
|
71
|
+
print_unformatted_to_stderr(e)
|
|
77
72
|
# This was the only way I could make this work, exiting on another thread than main
|
|
78
73
|
os._exit(1)
|
|
79
74
|
else:
|
|
@@ -91,7 +86,7 @@ def _connect_to_broker(
|
|
|
91
86
|
def on_signals(frame: SignalsInFrame) -> None:
|
|
92
87
|
global _has_received_signal # noqa: PLW0603
|
|
93
88
|
if not _has_received_signal:
|
|
94
|
-
|
|
89
|
+
print_generic_message("Bridge-app is properly receiving signals, you are good to go :thumbsup:")
|
|
95
90
|
_has_received_signal = True
|
|
96
91
|
|
|
97
92
|
for s in frame:
|
|
@@ -114,42 +109,42 @@ def grpc_connect(
|
|
|
114
109
|
on_signals: Any, signals_to_subscribe_to: Union[List[SignalIdentifier], None] = None, on_change_only: bool = False
|
|
115
110
|
) -> None:
|
|
116
111
|
try:
|
|
117
|
-
|
|
112
|
+
print_generic_message("Connecting and subscribing to broker...")
|
|
118
113
|
subscription = None
|
|
119
114
|
client = Client(client_id="cli")
|
|
120
115
|
client.connect(url=broker, api_key=x_api_key)
|
|
121
116
|
client.on_signals = on_signals
|
|
122
117
|
|
|
123
118
|
if signals_to_subscribe_to is None:
|
|
124
|
-
print
|
|
119
|
+
# TODO: use logs instead of print?
|
|
120
|
+
print_generic_error("No signals to subscribe to")
|
|
125
121
|
return
|
|
126
122
|
subscription = client.subscribe(signals_to_subscribe_to=signals_to_subscribe_to, changed_values_only=on_change_only)
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
print_generic_message("Subscription to broker completed")
|
|
124
|
+
print_generic_message("Waiting for signals...")
|
|
129
125
|
|
|
130
126
|
while True:
|
|
131
127
|
time.sleep(1)
|
|
132
128
|
|
|
133
129
|
except grpc.RpcError as e:
|
|
134
|
-
|
|
130
|
+
print_generic_error("Problems connecting or subscribing")
|
|
135
131
|
if isinstance(e, grpc.Call):
|
|
136
|
-
|
|
132
|
+
print_generic_error(f"{e.code()} - {e.details()}")
|
|
137
133
|
else:
|
|
138
|
-
|
|
134
|
+
print_generic_error(e)
|
|
139
135
|
|
|
140
136
|
except BrokerException as e:
|
|
141
|
-
|
|
137
|
+
print_generic_error(e)
|
|
142
138
|
if subscription is not None:
|
|
143
139
|
subscription.cancel()
|
|
144
140
|
|
|
145
141
|
except KeyboardInterrupt:
|
|
146
|
-
|
|
142
|
+
print_generic_message("Keyboard interrupt received. Closing subscription.")
|
|
147
143
|
if subscription is not None:
|
|
148
144
|
subscription.cancel()
|
|
149
145
|
|
|
150
146
|
except Exception as e:
|
|
151
|
-
|
|
152
|
-
err_console.print(f":boom: {e}")
|
|
147
|
+
print_generic_error(e)
|
|
153
148
|
|
|
154
149
|
|
|
155
150
|
def do_connect( # noqa: PLR0913
|
|
@@ -168,7 +163,7 @@ def do_connect( # noqa: PLR0913
|
|
|
168
163
|
|
|
169
164
|
if broker_url.startswith("https"):
|
|
170
165
|
if api_key is None:
|
|
171
|
-
|
|
166
|
+
print_generic_message("No --api-key, reading token from file")
|
|
172
167
|
x_api_key = settings.get_active_token_secret()
|
|
173
168
|
else:
|
|
174
169
|
x_api_key = api_key
|
|
@@ -176,18 +171,15 @@ def do_connect( # noqa: PLR0913
|
|
|
176
171
|
x_api_key = api_key
|
|
177
172
|
try:
|
|
178
173
|
io.connect(address)
|
|
179
|
-
# if config is None:
|
|
180
|
-
# raise ValueError("Config is None")
|
|
181
174
|
config_path = config
|
|
182
175
|
while is_connected is None:
|
|
183
176
|
time.sleep(1)
|
|
184
|
-
# if expression is not None:
|
|
185
177
|
_connect_to_broker(signals_to_subscribe_to=signals, config=config, expression=expression, on_change_only=on_change_only)
|
|
186
178
|
except SocketIoConnectionError as e:
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
print_generic_error("Failed to connect to ProtoPie Connect")
|
|
180
|
+
print_unformatted_to_stderr(e)
|
|
189
181
|
sys.exit(1)
|
|
190
182
|
except Exception as e:
|
|
191
|
-
|
|
192
|
-
|
|
183
|
+
print_generic_error("Unexpected error")
|
|
184
|
+
print_unformatted_to_stderr(e)
|
|
193
185
|
sys.exit(1)
|
cli/remotive.py
CHANGED
|
@@ -3,16 +3,13 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
|
-
from rich import print as rich_print
|
|
7
|
-
from rich.console import Console
|
|
8
6
|
from trogon import Trogon
|
|
9
7
|
from typer.main import get_group
|
|
10
8
|
|
|
11
|
-
from cli.broker
|
|
12
|
-
from cli.cloud
|
|
9
|
+
from cli.broker import app as broker_app
|
|
10
|
+
from cli.cloud import app as cloud_app
|
|
13
11
|
from cli.connect.connect import app as connect_app
|
|
14
|
-
from cli.settings import settings
|
|
15
|
-
from cli.settings.core import Settings
|
|
12
|
+
from cli.settings import Settings, settings
|
|
16
13
|
from cli.settings.migration.migrate_all_token_files import migrate_any_legacy_tokens
|
|
17
14
|
from cli.settings.migration.migrate_config_file import migrate_config_file
|
|
18
15
|
from cli.settings.migration.migrate_legacy_dirs import migrate_legacy_settings_dirs
|
|
@@ -20,8 +17,7 @@ from cli.tools.tools import app as tools_app
|
|
|
20
17
|
from cli.topology.cmd import app as topology_app
|
|
21
18
|
from cli.typer import typer_utils
|
|
22
19
|
from cli.utils import versions
|
|
23
|
-
|
|
24
|
-
err_console = Console(stderr=True)
|
|
20
|
+
from cli.utils.console import print_generic_error, print_generic_message
|
|
25
21
|
|
|
26
22
|
|
|
27
23
|
def is_featue_flag_enabled(env_var: str) -> bool:
|
|
@@ -49,7 +45,7 @@ def version_callback(value: bool) -> None:
|
|
|
49
45
|
|
|
50
46
|
def test_callback(value: int) -> None:
|
|
51
47
|
if value:
|
|
52
|
-
|
|
48
|
+
print_generic_message(str(value))
|
|
53
49
|
raise typer.Exit()
|
|
54
50
|
|
|
55
51
|
|
|
@@ -73,7 +69,7 @@ def run_migrations(settings: Settings) -> None:
|
|
|
73
69
|
migrate_config_file(settings.config_file_path, settings)
|
|
74
70
|
|
|
75
71
|
if has_migrated_tokens:
|
|
76
|
-
|
|
72
|
+
print_generic_error("Migrated old credentials and configuration files, you may need to login again or activate correct credentials")
|
|
77
73
|
|
|
78
74
|
|
|
79
75
|
def set_default_org_as_env(settings: Settings) -> None:
|
|
@@ -82,7 +78,7 @@ def set_default_org_as_env(settings: Settings) -> None:
|
|
|
82
78
|
This has to be done early before it is read
|
|
83
79
|
"""
|
|
84
80
|
if "REMOTIVE_CLOUD_ORGANIZATION" not in os.environ:
|
|
85
|
-
active_account = settings.
|
|
81
|
+
active_account = settings.get_active_account()
|
|
86
82
|
if active_account and active_account.default_organization:
|
|
87
83
|
os.environ["REMOTIVE_CLOUD_ORGANIZATION"] = active_account.default_organization
|
|
88
84
|
|
|
@@ -113,21 +109,15 @@ def tui(ctx: typer.Context) -> None:
|
|
|
113
109
|
|
|
114
110
|
|
|
115
111
|
app.add_typer(broker_app, name="broker", help="Manage a single broker - local or cloud")
|
|
116
|
-
app.add_typer(
|
|
117
|
-
cloud_app,
|
|
118
|
-
name="cloud",
|
|
119
|
-
help="Manage resources in RemotiveCloud",
|
|
120
|
-
)
|
|
112
|
+
app.add_typer(cloud_app, name="cloud", help="Manage resources in RemotiveCloud")
|
|
121
113
|
app.add_typer(connect_app, name="connect", help="Integrations with other systems")
|
|
122
114
|
app.add_typer(tools_app, name="tools")
|
|
115
|
+
app.add_typer(
|
|
116
|
+
topology_app,
|
|
117
|
+
name="topology",
|
|
118
|
+
help="""
|
|
119
|
+
Interact and manage RemotiveTopology resources
|
|
123
120
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
name="topology",
|
|
128
|
-
help="""
|
|
129
|
-
RemotiveTopology actions
|
|
130
|
-
|
|
131
|
-
Read more at https://docs.remotivelabs.com/docs/remotive-topology
|
|
132
|
-
""",
|
|
133
|
-
)
|
|
121
|
+
Read more at https://docs.remotivelabs.com/docs/remotive-topology
|
|
122
|
+
""",
|
|
123
|
+
)
|
cli/settings/__init__.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from cli.settings.config_file import Account, ConfigFile
|
|
2
2
|
from cli.settings.config_file import dumps as dumps_config_file
|
|
3
3
|
from cli.settings.config_file import loads as loads_config_file
|
|
4
|
-
from cli.settings.core import InvalidSettingsFilePathError, Settings,
|
|
4
|
+
from cli.settings.core import InvalidSettingsFilePathError, Settings, settings
|
|
5
5
|
from cli.settings.token_file import TokenFile
|
|
6
6
|
from cli.settings.token_file import dumps as dumps_token_file
|
|
7
7
|
from cli.settings.token_file import loads as loads_token_file
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
"settings",
|
|
11
|
-
"TokenNotFoundError",
|
|
12
11
|
"InvalidSettingsFilePathError",
|
|
13
12
|
"Settings",
|
|
14
13
|
"TokenFile",
|