Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ovos_config references, Read config in get_mycroft_bus #72

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ovos_utils/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

from ovos_utils.bracket_expansion import expand_options
from ovos_utils.configuration import read_mycroft_config
from ovos_config.config import read_mycroft_config
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.lang import translate_word
from ovos_utils.log import LOG
Expand Down
2 changes: 1 addition & 1 deletion ovos_utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def resolve_resource_file(res_name, root_path=None, config=None):
str: path to resource or None if no resource found
"""
if config is None:
from ovos_utils.configuration import read_mycroft_config
from ovos_config.config import read_mycroft_config
config = read_mycroft_config()

# First look for fully qualified file (e.g. a user setting)
Expand Down
4 changes: 2 additions & 2 deletions ovos_utils/fingerprinting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from os.path import join, isfile
from ovos_utils.system import is_installed, is_running_from_module, has_screen, \
get_desktop_environment, search_mycroft_core_location, is_process_running
from ovos_utils.configuration import is_using_xdg
from ovos_config.meta import is_using_xdg


class MycroftPlatform(str, Enum):
Expand All @@ -28,7 +28,7 @@ def detect_platform():

def get_config_fingerprint(config=None):
if not config:
from ovos_utils.configuration import read_mycroft_config
from ovos_config.config import read_mycroft_config
config = read_mycroft_config()
conf = config
listener_conf = conf.get("listener", {})
Expand Down
22 changes: 20 additions & 2 deletions ovos_utils/messagebus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import Optional

from mycroft_bus_client import MessageBusClient
from mycroft_bus_client.message import dig_for_message, Message
from ovos_utils.log import LOG
from ovos_utils.configuration import read_mycroft_config, get_default_lang
from ovos_config.config import read_mycroft_config
from ovos_config.locale import get_default_lang
from ovos_utils import create_loop
from ovos_utils.json_helper import merge_dict
import time
Expand All @@ -10,6 +13,12 @@
from threading import Event


_DEFAULT_WS_CONFIG = {"host": "0.0.0.0",
"port": 8181,
"route": "/core",
"ssl": False}


class FakeBus:
def __init__(self, *args, **kwargs):
self.started_running = False
Expand Down Expand Up @@ -135,10 +144,19 @@ def get_websocket(host, port, route='/', ssl=False, threaded=True):
return client


def get_mycroft_bus(host='0.0.0.0', port=8181, route='/core', ssl=False):
def get_mycroft_bus(host: str = None, port: int = 8181, route: str = '/core',
NeonDaniel marked this conversation as resolved.
Show resolved Hide resolved
ssl: Optional[bool] = None):
"""
Returns a connection to the mycroft messagebus
"""
from ovos_config.config import read_mycroft_config
config = read_mycroft_config().get('websocket') or dict()
host = host or config.get('host') or _DEFAULT_WS_CONFIG['host']
port = port or config.get('port') or _DEFAULT_WS_CONFIG['port']
route = route or config.get('route') or _DEFAULT_WS_CONFIG['route']
if ssl is None:
ssl = config.get('ssl') if 'ssl' in config else \
_DEFAULT_WS_CONFIG['ssl']
return get_websocket(host, port, route, ssl)


Expand Down
2 changes: 1 addition & 1 deletion ovos_utils/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_ipc_directory(domain=None, config=None):
str: a path to the IPC directory
"""
if config is None:
from ovos_utils.configuration import read_mycroft_config
from ovos_config.config import read_mycroft_config
config = read_mycroft_config()
path = config.get("ipc_path")
if not path:
Expand Down