From ec6393996c1e1c813fe2a5c2ce0ab652595107f8 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:06:14 +0100 Subject: [PATCH] feat/identity (#36) --- hivemind_voice_satellite/__main__.py | 25 ++++++++++++++++++++----- requirements.txt | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hivemind_voice_satellite/__main__.py b/hivemind_voice_satellite/__main__.py index e21c3be..2dfb075 100644 --- a/hivemind_voice_satellite/__main__.py +++ b/hivemind_voice_satellite/__main__.py @@ -4,18 +4,33 @@ from ovos_utils import wait_for_exit_signal from ovos_utils.log import init_service_logger, LOG from hivemind_voice_satellite import VoiceClient +from hivemind_bus_client.identity import NodeIdentity @click.command(help="connect to HiveMind") -@click.option("--host", help="hivemind host", type=str, default="wss://127.0.0.1") -@click.option("--key", help="Access Key", type=str) -@click.option("--password", help="Password for key derivation", type=str) +@click.option("--host", help="hivemind host", type=str, default="") +@click.option("--key", help="Access Key", type=str, default="") +@click.option("--password", help="Password for key derivation", type=str, default="") @click.option("--port", help="HiveMind port number", type=int, default=5678) @click.option("--selfsigned", help="accept self signed certificates", is_flag=True) -@click.option("--siteid", help="location identifier for message.context", type=str, default="unknown") +@click.option("--siteid", help="location identifier for message.context", type=str, default="") def connect(host, key, password, port, selfsigned, siteid): + init_service_logger("HiveMind-voice-sat") - + + identity = NodeIdentity() + password = password or identity.password + key = key or identity.access_key + siteid = siteid or identity.site_id or "unknown" + host = host or identity.default_master + + if not host.startswith("ws://") and not host.startswith("wss://"): + host = "ws://" + host + + if not key or not password or not host: + raise RuntimeError("NodeIdentity not set, please pass key/password/host or " + "call 'hivemind-client set-identity'") + if not host.startswith("ws"): LOG.error("Invalid host, please specify a protocol") LOG.error(f"ws://{host} or wss://{host}") diff --git a/requirements.txt b/requirements.txt index 2cbc489..09b6554 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -hivemind_bus_client>=0.0.4a8 +hivemind_bus_client>=0.0.4a10 ovos-audio ovos-dinkum-listener>=0.0.2, < 0.1.0 ovos-vad-plugin-webrtcvad