PEP8
commit
131a9ed03f
|
@ -52,12 +52,12 @@ pipeline {
|
||||||
--label build=${JOB_NAME} \
|
--label build=${JOB_NAME} \
|
||||||
-t voight-kampff-mark-1:${BRANCH_ALIAS} .'
|
-t voight-kampff-mark-1:${BRANCH_ALIAS} .'
|
||||||
echo 'Running Mark I Voight-Kampff Test Suite'
|
echo 'Running Mark I Voight-Kampff Test Suite'
|
||||||
timeout(time: 60, unit: 'MINUTES')
|
timeout(time: 90, unit: 'MINUTES')
|
||||||
{
|
{
|
||||||
sh 'mkdir -p $HOME/core/$BRANCH_ALIAS/allure'
|
sh 'mkdir -p $HOME/core/$BRANCH_ALIAS/allure'
|
||||||
sh 'mkdir -p $HOME/core/$BRANCH_ALIAS/mycroft-logs'
|
sh 'mkdir -p $HOME/core/$BRANCH_ALIAS/mycroft-logs'
|
||||||
sh 'docker run \
|
sh 'docker run \
|
||||||
-v "$HOME/voight-kampff/identity:/root/.mycroft/identity" \
|
-v "$HOME/voight-kampff/identity:/root/.config/mycroft/identity" \
|
||||||
-v "$HOME/core/$BRANCH_ALIAS/allure:/root/allure" \
|
-v "$HOME/core/$BRANCH_ALIAS/allure:/root/allure" \
|
||||||
-v "$HOME/core/$BRANCH_ALIAS/mycroft-logs:/var/log/mycroft" \
|
-v "$HOME/core/$BRANCH_ALIAS/mycroft-logs:/var/log/mycroft" \
|
||||||
--label build=${JOB_NAME} \
|
--label build=${JOB_NAME} \
|
||||||
|
|
|
@ -73,20 +73,20 @@ Mycroft is nothing without skills. There are a handful of default skills that a
|
||||||
|
|
||||||
### Pairing Information
|
### Pairing Information
|
||||||
Pairing information generated by registering with Home is stored in:
|
Pairing information generated by registering with Home is stored in:
|
||||||
`~/.mycroft/identity/identity2.json` <b><-- DO NOT SHARE THIS WITH OTHERS!</b>
|
`~/.config/mycroft/identity/identity2.json` <b><-- DO NOT SHARE THIS WITH OTHERS!</b>
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
Mycroft's configuration consists of 4 possible locations:
|
Mycroft's configuration consists of 4 possible locations:
|
||||||
- `mycroft-core/mycroft/configuration/mycroft.conf`(Defaults)
|
- `mycroft-core/mycroft/configuration/mycroft.conf`(Defaults)
|
||||||
- [Mycroft Home](https://home.mycroft.ai) (Remote)
|
- [Mycroft Home](https://home.mycroft.ai) (Remote)
|
||||||
- `/etc/mycroft/mycroft.conf`(Machine)
|
- `/etc/mycroft/mycroft.conf` (Machine)
|
||||||
- `$HOME/.mycroft/mycroft.conf`(User)
|
- `$XDG_CONFIG_DIR/mycroft/mycroft.conf` (which is by default `$HOME/.config/mycroft/mycroft.conf`) (USER)
|
||||||
|
|
||||||
When the configuration loader starts, it looks in these locations in this order, and loads ALL configurations. Keys that exist in multiple configuration files will be overridden by the last file to contain the value. This process results in a minimal amount being written for a specific device and user, without modifying default distribution files.
|
When the configuration loader starts, it looks in these locations in this order, and loads ALL configurations. Keys that exist in multiple configuration files will be overridden by the last file to contain the value. This process results in a minimal amount being written for a specific device and user, without modifying default distribution files.
|
||||||
|
|
||||||
### Using Mycroft Without Home
|
### Using Mycroft Without Home
|
||||||
|
|
||||||
If you do not wish to use the Mycroft Home service, before starting Mycroft for the first time, create `$HOME/.mycroft/mycroft.conf` with the following contents:
|
If you do not wish to use the Mycroft Home service, before starting Mycroft for the first time, create `$HOME/.config/mycroft/mycroft.conf` with the following contents:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,13 +95,13 @@ function validate_config_file() {
|
||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
|
|
||||||
_conf_file="~/.mycroft/mycroft.conf"
|
_conf_file="${XDG_CONFIG_HOME:-$HOME/.config}/mycroft/mycroft.conf"
|
||||||
function name_to_path() {
|
function name_to_path() {
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"system") _conf_file="/etc/mycroft/mycroft.conf" ;;
|
"system") _conf_file="/etc/mycroft/mycroft.conf" ;;
|
||||||
"user") _conf_file=$(readlink -f ~/.mycroft/mycroft.conf) ;;
|
"user") _conf_file=$(readlink -f ${XDG_CONFIG_HOME:-$HOME/.config}/mycroft/mycroft.conf) ;;
|
||||||
"default") _conf_file="$DIR/../mycroft/configuration/mycroft.conf" ;;
|
"default") _conf_file="$DIR/../mycroft/configuration/mycroft.conf" ;;
|
||||||
"remote") _conf_file="/var/tmp/mycroft_web_cache.json" ;;
|
"remote") _conf_file="$HOME/.cache/mycroft/web_cache.json" ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "ERROR: Unknown name '${1}'."
|
echo "ERROR: Unknown name '${1}'."
|
||||||
|
|
|
@ -366,7 +366,7 @@ function open_suse_install() {
|
||||||
|
|
||||||
|
|
||||||
function fedora_install() {
|
function fedora_install() {
|
||||||
$SUDO dnf install -y git python3 python3-devel python3-pip python3-setuptools python3-virtualenv pygobject3-devel libtool libffi-devel openssl-devel autoconf bison swig glib2-devel portaudio-devel mpg123 mpg123-plugins-pulseaudio screen curl pkgconfig libicu-devel automake libjpeg-turbo-devel fann-devel gcc-c++ redhat-rpm-config jq make
|
$SUDO dnf install -y git python3 python3-devel python3-pip python3-setuptools python3-virtualenv pygobject3-devel libtool libffi-devel openssl-devel autoconf bison swig glib2-devel portaudio-devel mpg123 mpg123-plugins-pulseaudio screen curl pkgconfig libicu-devel automake libjpeg-turbo-devel fann-devel gcc-c++ redhat-rpm-config jq make pulseaudio-utils
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ from mycroft.skills.context import adds_context, removes_context
|
||||||
from mycroft.skills import (MycroftSkill, FallbackSkill,
|
from mycroft.skills import (MycroftSkill, FallbackSkill,
|
||||||
intent_handler, intent_file_handler)
|
intent_handler, intent_file_handler)
|
||||||
from mycroft.skills.intent_service import AdaptIntent
|
from mycroft.skills.intent_service import AdaptIntent
|
||||||
|
from mycroft.util.log import LOG
|
||||||
|
|
||||||
MYCROFT_ROOT_PATH = abspath(join(dirname(__file__), '..'))
|
MYCROFT_ROOT_PATH = abspath(join(dirname(__file__), '..'))
|
||||||
|
|
||||||
|
@ -33,3 +34,5 @@ __all__ = ['MYCROFT_ROOT_PATH',
|
||||||
'intent_handler',
|
'intent_handler',
|
||||||
'intent_file_handler',
|
'intent_file_handler',
|
||||||
'AdaptIntent']
|
'AdaptIntent']
|
||||||
|
|
||||||
|
LOG.init() # read log level from config
|
||||||
|
|
|
@ -21,8 +21,6 @@ import requests
|
||||||
from requests import HTTPError, RequestException
|
from requests import HTTPError, RequestException
|
||||||
|
|
||||||
from mycroft.configuration import Configuration
|
from mycroft.configuration import Configuration
|
||||||
from mycroft.configuration.config import DEFAULT_CONFIG, SYSTEM_CONFIG, \
|
|
||||||
USER_CONFIG
|
|
||||||
from mycroft.identity import IdentityManager, identity_lock
|
from mycroft.identity import IdentityManager, identity_lock
|
||||||
from mycroft.version import VersionManager
|
from mycroft.version import VersionManager
|
||||||
from mycroft.util import get_arch, connected, LOG
|
from mycroft.util import get_arch, connected, LOG
|
||||||
|
@ -62,15 +60,12 @@ class Api:
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
# Load the config, skipping the REMOTE_CONFIG since we are
|
# Load the config, skipping the remote config since we are
|
||||||
# getting the info needed to get to it!
|
# getting the info needed to get to it!
|
||||||
self.config = Configuration.get([DEFAULT_CONFIG,
|
config = Configuration.get(cache=False, remote=False)
|
||||||
SYSTEM_CONFIG,
|
config_server = config.get("server")
|
||||||
USER_CONFIG],
|
self.url = config_server.get("url")
|
||||||
cache=False)
|
self.version = config_server.get("version")
|
||||||
server_config = self.config.get("server")
|
|
||||||
self.url = server_config.get("url")
|
|
||||||
self.version = server_config.get("version")
|
|
||||||
self.identity = IdentityManager.get()
|
self.identity = IdentityManager.get()
|
||||||
|
|
||||||
def request(self, params):
|
def request(self, params):
|
||||||
|
@ -239,7 +234,6 @@ class DeviceApi(Api):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("device")
|
super().__init__("device")
|
||||||
self.enclosure_config = self.config.get("enclosure")
|
|
||||||
|
|
||||||
def get_code(self, state):
|
def get_code(self, state):
|
||||||
IdentityManager.update()
|
IdentityManager.update()
|
||||||
|
@ -253,10 +247,12 @@ class DeviceApi(Api):
|
||||||
platform_build = ""
|
platform_build = ""
|
||||||
pantacor_device_id = None
|
pantacor_device_id = None
|
||||||
|
|
||||||
if self.enclosure_config is not None:
|
# load just the local configs to get platform info
|
||||||
platform = self.enclosure_config.get("platform", "unknown")
|
config = Configuration.get(cache=False, remote=False)
|
||||||
platform_build = self.enclosure_config.get("platform_build", "")
|
if "enclosure" in config:
|
||||||
packaging_type = self.enclosure_config.get("packaging_type")
|
platform = config.get("enclosure").get("platform", "unknown")
|
||||||
|
platform_build = config.get("enclosure").get("platform_build", "")
|
||||||
|
packaging_type = config.get("enclosure").get("packaging_type")
|
||||||
if packaging_type is not None and packaging_type == "pantacor":
|
if packaging_type is not None and packaging_type == "pantacor":
|
||||||
pantacor_device_id = _get_pantacor_device_id()
|
pantacor_device_id = _get_pantacor_device_id()
|
||||||
|
|
||||||
|
@ -283,9 +279,7 @@ class DeviceApi(Api):
|
||||||
platform_build = ""
|
platform_build = ""
|
||||||
|
|
||||||
# load just the local configs to get platform info
|
# load just the local configs to get platform info
|
||||||
config = Configuration.get([SYSTEM_CONFIG,
|
config = Configuration.get(cache=False, remote=False)
|
||||||
USER_CONFIG],
|
|
||||||
cache=False)
|
|
||||||
if "enclosure" in config:
|
if "enclosure" in config:
|
||||||
platform = config.get("enclosure").get("platform", "unknown")
|
platform = config.get("enclosure").get("platform", "unknown")
|
||||||
platform_build = config.get("enclosure").get("platform_build", "")
|
platform_build = config.get("enclosure").get("platform_build", "")
|
||||||
|
|
|
@ -17,11 +17,12 @@
|
||||||
This provides any "enclosure" specific functionality, for example GUI or
|
This provides any "enclosure" specific functionality, for example GUI or
|
||||||
control over the Mark-1 Faceplate.
|
control over the Mark-1 Faceplate.
|
||||||
"""
|
"""
|
||||||
from mycroft.configuration import LocalConf, SYSTEM_CONFIG
|
from mycroft.configuration import Configuration
|
||||||
from mycroft.util.log import LOG
|
from mycroft.util.log import LOG
|
||||||
from mycroft.util import wait_for_exit_signal, reset_sigint_handler
|
from mycroft.util import wait_for_exit_signal, reset_sigint_handler
|
||||||
from mycroft.util.hardware_capabilities import EnclosureCapabilities
|
from mycroft.util.hardware_capabilities import EnclosureCapabilities
|
||||||
|
|
||||||
|
|
||||||
def on_ready():
|
def on_ready():
|
||||||
LOG.info("Enclosure started!")
|
LOG.info("Enclosure started!")
|
||||||
|
|
||||||
|
@ -70,8 +71,8 @@ def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
|
||||||
only the GUI bus will be started.
|
only the GUI bus will be started.
|
||||||
"""
|
"""
|
||||||
# Read the system configuration
|
# Read the system configuration
|
||||||
system_config = LocalConf(SYSTEM_CONFIG)
|
config = Configuration.get(remote=False)
|
||||||
platform = system_config.get("enclosure", {}).get("platform")
|
platform = config.get("enclosure", {}).get("platform")
|
||||||
|
|
||||||
enclosure = create_enclosure(platform)
|
enclosure = create_enclosure(platform)
|
||||||
|
|
||||||
|
@ -81,13 +82,17 @@ def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping):
|
||||||
# enclosure.m2enc.capabilities
|
# enclosure.m2enc.capabilities
|
||||||
enclosure.default_caps = EnclosureCapabilities()
|
enclosure.default_caps = EnclosureCapabilities()
|
||||||
|
|
||||||
LOG.info("Enclosure created, capabilities ===>%s" % (enclosure.default_caps.caps,))
|
LOG.info("Enclosure created, capabilities ===>%s" %
|
||||||
|
(enclosure.default_caps.caps,))
|
||||||
|
|
||||||
if platform == "mycroft_mark_2":
|
if platform == "mycroft_mark_2":
|
||||||
LOG.info("Mark2 detected[%s], additional capabilities ===>%s" % (enclosure.m2enc.board_type, enclosure.m2enc.capabilities))
|
LOG.info("Mark2 detected[%s], additional capabilities ===>%s" % (
|
||||||
|
enclosure.m2enc.board_type, enclosure.m2enc.capabilities))
|
||||||
LOG.info("Leds ===>%s" % (enclosure.m2enc.leds.capabilities))
|
LOG.info("Leds ===>%s" % (enclosure.m2enc.leds.capabilities))
|
||||||
LOG.info("Volume ===>%s" % (enclosure.m2enc.hardware_volume.capabilities))
|
LOG.info("Volume ===>%s" %
|
||||||
LOG.info("Switches ===>%s" % (enclosure.m2enc.switches.capabilities))
|
(enclosure.m2enc.hardware_volume.capabilities))
|
||||||
|
LOG.info("Switches ===>%s" %
|
||||||
|
(enclosure.m2enc.switches.capabilities))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.info("__main__().py Starting Client Enclosure!")
|
LOG.info("__main__().py Starting Client Enclosure!")
|
||||||
|
|
|
@ -14,12 +14,13 @@
|
||||||
#
|
#
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import sys
|
|
||||||
from alsaaudio import Mixer
|
from alsaaudio import Mixer
|
||||||
from threading import Thread, Timer
|
from threading import Thread, Timer
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
import mycroft.dialog
|
import mycroft.dialog
|
||||||
from mycroft.client.enclosure.base import Enclosure
|
from mycroft.client.enclosure.base import Enclosure
|
||||||
from mycroft.api import has_been_paired
|
from mycroft.api import has_been_paired
|
||||||
|
@ -29,7 +30,7 @@ from mycroft.client.enclosure.mark1.eyes import EnclosureEyes
|
||||||
from mycroft.client.enclosure.mark1.mouth import EnclosureMouth
|
from mycroft.client.enclosure.mark1.mouth import EnclosureMouth
|
||||||
from mycroft.enclosure.display_manager import \
|
from mycroft.enclosure.display_manager import \
|
||||||
init_display_manager_bus_connection
|
init_display_manager_bus_connection
|
||||||
from mycroft.configuration import Configuration, LocalConf, USER_CONFIG
|
from mycroft.configuration import LocalConf, USER_CONFIG
|
||||||
from mycroft.messagebus.message import Message
|
from mycroft.messagebus.message import Message
|
||||||
from mycroft.util import play_wav, create_signal, connected, check_for_signal
|
from mycroft.util import play_wav, create_signal, connected, check_for_signal
|
||||||
from mycroft.util.audio_test import record
|
from mycroft.util.audio_test import record
|
||||||
|
@ -164,6 +165,10 @@ class EnclosureReader(Thread):
|
||||||
if "unit.factory-reset" in data:
|
if "unit.factory-reset" in data:
|
||||||
self.bus.emit(Message("speak", {
|
self.bus.emit(Message("speak", {
|
||||||
'utterance': mycroft.dialog.get("reset to factory defaults")}))
|
'utterance': mycroft.dialog.get("reset to factory defaults")}))
|
||||||
|
subprocess.call(
|
||||||
|
(f'rm {xdg.BaseDirectory.save_config_path("mycroft")}'
|
||||||
|
'/mycroft/identity/identity2.json'),
|
||||||
|
shell=True)
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
'rm ~/.mycroft/identity/identity2.json',
|
'rm ~/.mycroft/identity/identity2.json',
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|
|
@ -26,13 +26,15 @@ import tempfile
|
||||||
from threading import Timer, Thread
|
from threading import Timer, Thread
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
from petact import install_package
|
from petact import install_package
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from mycroft.configuration import Configuration, LocalConf, USER_CONFIG
|
from mycroft.configuration import Configuration, LocalConf
|
||||||
from mycroft.util.monotonic_event import MonotonicEvent
|
from mycroft.configuration.locations import OLD_USER_CONFIG
|
||||||
from mycroft.util.log import LOG
|
from mycroft.util.log import LOG
|
||||||
|
from mycroft.util.monotonic_event import MonotonicEvent
|
||||||
from mycroft.util.plugins import load_plugin
|
from mycroft.util.plugins import load_plugin
|
||||||
|
|
||||||
RECOGNIZER_DIR = join(abspath(dirname(__file__)), "recognizer")
|
RECOGNIZER_DIR = join(abspath(dirname(__file__)), "recognizer")
|
||||||
|
@ -193,9 +195,31 @@ class PreciseHotword(HotWordEngine):
|
||||||
from precise_runner import (
|
from precise_runner import (
|
||||||
PreciseRunner, PreciseEngine, ReadWriteStream
|
PreciseRunner, PreciseEngine, ReadWriteStream
|
||||||
)
|
)
|
||||||
local_conf = LocalConf(USER_CONFIG)
|
|
||||||
|
# We need to save to a writeable location, but the key we need
|
||||||
|
# might be stored in a different, unwriteable, location
|
||||||
|
# Make sure we pick the key we need from wherever it's located,
|
||||||
|
# but save to a writeable location only
|
||||||
|
local_conf = LocalConf(
|
||||||
|
join(xdg.BaseDirectory.save_config_path('mycroft'), 'mycroft.conf')
|
||||||
|
)
|
||||||
|
|
||||||
|
for conf_dir in xdg.BaseDirectory.load_config_paths('mycroft'):
|
||||||
|
conf = LocalConf(join(conf_dir, 'mycroft.conf'))
|
||||||
|
# If the current config contains the precise key use it,
|
||||||
|
# otherwise continue to the next file
|
||||||
|
if conf.get('precise', None) is not None:
|
||||||
|
local_conf['precise'] = conf.get('precise', None)
|
||||||
|
break
|
||||||
|
|
||||||
|
# If the key is not found yet, it might still exist on the old
|
||||||
|
# (deprecated) location
|
||||||
|
if local_conf.get('precise', None) is None:
|
||||||
|
local_conf = LocalConf(OLD_USER_CONFIG)
|
||||||
|
|
||||||
if not local_conf.get('precise', {}).get('use_precise', True):
|
if not local_conf.get('precise', {}).get('use_precise', True):
|
||||||
raise PreciseUnavailable
|
raise PreciseUnavailable
|
||||||
|
|
||||||
if (local_conf.get('precise', {}).get('dist_url') ==
|
if (local_conf.get('precise', {}).get('dist_url') ==
|
||||||
'http://bootstrap.mycroft.ai/artifacts/static/daily/'):
|
'http://bootstrap.mycroft.ai/artifacts/static/daily/'):
|
||||||
del local_conf['precise']['dist_url']
|
del local_conf['precise']['dist_url']
|
||||||
|
@ -252,7 +276,10 @@ class PreciseHotword(HotWordEngine):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def folder(self):
|
def folder(self):
|
||||||
return join(expanduser('~'), '.mycroft', 'precise')
|
old_path = join(expanduser('~'), '.mycroft', 'precise')
|
||||||
|
if os.path.isdir(old_path):
|
||||||
|
return old_path
|
||||||
|
return xdg.BaseDirectory.save_data_path('mycroft', 'precise')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def install_destination(self):
|
def install_destination(self):
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
from .gui_server import start_qml_gui
|
from .gui_server import start_qml_gui
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ def handleNonAscii(text):
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Settings
|
# Settings
|
||||||
|
|
||||||
config_file = os.path.join(os.path.expanduser("~"), ".mycroft_cli.conf")
|
filename = "mycroft_cli.conf"
|
||||||
|
|
||||||
|
|
||||||
def load_mycroft_config(bus):
|
def load_mycroft_config(bus):
|
||||||
|
@ -171,6 +172,35 @@ def load_settings():
|
||||||
global max_log_lines
|
global max_log_lines
|
||||||
global show_meter
|
global show_meter
|
||||||
|
|
||||||
|
config_file = None
|
||||||
|
|
||||||
|
# Old location
|
||||||
|
path = os.path.join(os.path.expanduser("~"), ".mycroft_cli.conf")
|
||||||
|
if os.path.isfile(path):
|
||||||
|
LOG.warning(" ===============================================")
|
||||||
|
LOG.warning(" == DEPRECATION WARNING ==")
|
||||||
|
LOG.warning(" ===============================================")
|
||||||
|
LOG.warning(" You still have a config file at " +
|
||||||
|
path)
|
||||||
|
LOG.warning(" Note that this location is deprecated and will" +
|
||||||
|
" not be used in the future")
|
||||||
|
LOG.warning(" Please move it to " +
|
||||||
|
os.path.join(xdg.BaseDirectory.save_config_path('mycroft'),
|
||||||
|
filename))
|
||||||
|
config_file = path
|
||||||
|
|
||||||
|
# Check XDG_CONFIG_DIR
|
||||||
|
if config_file is None:
|
||||||
|
for conf_dir in xdg.BaseDirectory.load_config_paths('mycroft'):
|
||||||
|
xdg_file = os.path.join(conf_dir, filename)
|
||||||
|
if os.path.isfile(xdg_file):
|
||||||
|
config_file = xdg_file
|
||||||
|
break
|
||||||
|
|
||||||
|
# Check /etc/mycroft
|
||||||
|
if config_file is None:
|
||||||
|
config_file = os.path.join("/etc/mycroft", filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with io.open(config_file, 'r') as f:
|
with io.open(config_file, 'r') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
@ -196,6 +226,10 @@ def save_settings():
|
||||||
config["show_last_key"] = show_last_key
|
config["show_last_key"] = show_last_key
|
||||||
config["max_log_lines"] = max_log_lines
|
config["max_log_lines"] = max_log_lines
|
||||||
config["show_meter"] = show_meter
|
config["show_meter"] = show_meter
|
||||||
|
|
||||||
|
config_file = os.path.join(
|
||||||
|
xdg.BaseDirectory.save_config_path("mycroft"), filename)
|
||||||
|
|
||||||
with io.open(config_file, 'w') as f:
|
with io.open(config_file, 'w') as f:
|
||||||
f.write(str(json.dumps(config, ensure_ascii=False)))
|
f.write(str(json.dumps(config, ensure_ascii=False)))
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,19 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import re
|
|
||||||
import json
|
|
||||||
import inflection
|
import inflection
|
||||||
from os.path import exists, isfile
|
import json
|
||||||
|
from os.path import exists, isfile, join
|
||||||
|
import re
|
||||||
|
|
||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
from mycroft.util.json_helper import load_commented_json, merge_dict
|
from mycroft.util.json_helper import load_commented_json, merge_dict
|
||||||
from mycroft.util.log import LOG
|
from mycroft.util.log import LOG
|
||||||
|
|
||||||
from .locations import (DEFAULT_CONFIG, SYSTEM_CONFIG, USER_CONFIG,
|
from .locations import DEFAULT_CONFIG, USER_CONFIG, OLD_USER_CONFIG
|
||||||
WEB_CONFIG_CACHE)
|
from .locations import SYSTEM_CONFIG
|
||||||
|
|
||||||
|
|
||||||
def is_remote_list(values):
|
def is_remote_list(values):
|
||||||
|
@ -127,7 +129,8 @@ class RemoteConf(LocalConf):
|
||||||
def __init__(self, cache=None):
|
def __init__(self, cache=None):
|
||||||
super(RemoteConf, self).__init__(None)
|
super(RemoteConf, self).__init__(None)
|
||||||
|
|
||||||
cache = cache or WEB_CONFIG_CACHE
|
cache = cache or join(xdg.BaseDirectory.save_cache_path('mycroft'),
|
||||||
|
'web_cache.json')
|
||||||
from mycroft.api import is_paired
|
from mycroft.api import is_paired
|
||||||
if not is_paired():
|
if not is_paired():
|
||||||
self.load_local(cache)
|
self.load_local(cache)
|
||||||
|
@ -168,13 +171,24 @@ class RemoteConf(LocalConf):
|
||||||
self.load_local(cache)
|
self.load_local(cache)
|
||||||
|
|
||||||
|
|
||||||
|
def _log_old_location_deprecation():
|
||||||
|
LOG.warning("\n ===============================================\n"
|
||||||
|
" == DEPRECATION WARNING ==\n"
|
||||||
|
" ===============================================\n"
|
||||||
|
f" You still have a config file at {OLD_USER_CONFIG}\n"
|
||||||
|
" Note that this location is deprecated and will"
|
||||||
|
" not be used in the future\n"
|
||||||
|
" Please move it to "
|
||||||
|
f"{xdg.BaseDirectory.save_config_path('mycroft')}")
|
||||||
|
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
"""Namespace for operations on the configuration singleton."""
|
"""Namespace for operations on the configuration singleton."""
|
||||||
__config = {} # Cached config
|
__config = {} # Cached config
|
||||||
__patch = {} # Patch config that skills can update to override config
|
__patch = {} # Patch config that skills can update to override config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(configs=None, cache=True):
|
def get(configs=None, cache=True, remote=True):
|
||||||
"""Get configuration
|
"""Get configuration
|
||||||
|
|
||||||
Returns cached instance if available otherwise builds a new
|
Returns cached instance if available otherwise builds a new
|
||||||
|
@ -183,6 +197,7 @@ class Configuration:
|
||||||
Args:
|
Args:
|
||||||
configs (list): List of configuration dicts
|
configs (list): List of configuration dicts
|
||||||
cache (boolean): True if the result should be cached
|
cache (boolean): True if the result should be cached
|
||||||
|
remote (boolean): False if the Remote settings shouldn't be loaded
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(dict) configuration dictionary.
|
(dict) configuration dictionary.
|
||||||
|
@ -190,23 +205,50 @@ class Configuration:
|
||||||
if Configuration.__config:
|
if Configuration.__config:
|
||||||
return Configuration.__config
|
return Configuration.__config
|
||||||
else:
|
else:
|
||||||
return Configuration.load_config_stack(configs, cache)
|
return Configuration.load_config_stack(configs, cache, remote)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_config_stack(configs=None, cache=False):
|
def load_config_stack(configs=None, cache=False, remote=True):
|
||||||
"""Load a stack of config dicts into a single dict
|
"""Load a stack of config dicts into a single dict
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
configs (list): list of dicts to load
|
configs (list): list of dicts to load
|
||||||
cache (boolean): True if result should be cached
|
cache (boolean): True if result should be cached
|
||||||
|
remote (boolean): False if the Mycroft Home settings shouldn't
|
||||||
|
be loaded
|
||||||
Returns:
|
Returns:
|
||||||
(dict) merged dict of all configuration files
|
(dict) merged dict of all configuration files
|
||||||
"""
|
"""
|
||||||
if not configs:
|
if not configs:
|
||||||
configs = [LocalConf(DEFAULT_CONFIG), RemoteConf(),
|
configs = []
|
||||||
LocalConf(SYSTEM_CONFIG), LocalConf(USER_CONFIG),
|
|
||||||
Configuration.__patch]
|
# First use the patched config
|
||||||
|
configs.append(Configuration.__patch)
|
||||||
|
|
||||||
|
# Then use XDG config
|
||||||
|
# This includes both the user config and
|
||||||
|
# /etc/xdg/mycroft/mycroft.conf
|
||||||
|
for conf_dir in xdg.BaseDirectory.load_config_paths('mycroft'):
|
||||||
|
configs.append(LocalConf(join(conf_dir, 'mycroft.conf')))
|
||||||
|
|
||||||
|
# Then check the old user config
|
||||||
|
if isfile(OLD_USER_CONFIG):
|
||||||
|
_log_old_location_deprecation()
|
||||||
|
configs.append(LocalConf(OLD_USER_CONFIG))
|
||||||
|
|
||||||
|
# Then use remote config
|
||||||
|
if remote:
|
||||||
|
configs.append(RemoteConf())
|
||||||
|
|
||||||
|
# Then use the system config (/etc/mycroft/mycroft.conf)
|
||||||
|
configs.append(LocalConf(SYSTEM_CONFIG))
|
||||||
|
|
||||||
|
# Then use the config that comes with the package
|
||||||
|
configs.append(LocalConf(DEFAULT_CONFIG))
|
||||||
|
|
||||||
|
# Make sure we reverse the array, as merge_dict will put every new
|
||||||
|
# file on top of the previous one
|
||||||
|
configs = reversed(configs)
|
||||||
else:
|
else:
|
||||||
# Handle strings in stack
|
# Handle strings in stack
|
||||||
for index, item in enumerate(configs):
|
for index, item in enumerate(configs):
|
||||||
|
|
|
@ -14,10 +14,18 @@
|
||||||
import os
|
import os
|
||||||
from os.path import join, dirname, expanduser, exists
|
from os.path import join, dirname, expanduser, exists
|
||||||
|
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
|
DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
|
||||||
SYSTEM_CONFIG = os.environ.get('MYCROFT_SYSTEM_CONFIG',
|
SYSTEM_CONFIG = os.environ.get('MYCROFT_SYSTEM_CONFIG',
|
||||||
'/etc/mycroft/mycroft.conf')
|
'/etc/mycroft/mycroft.conf')
|
||||||
USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
|
# TODO: remove in 22.02
|
||||||
|
# Make sure we support the old location still
|
||||||
|
# Deprecated and will be removed eventually
|
||||||
|
OLD_USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
|
||||||
|
USER_CONFIG = join(xdg.BaseDirectory.save_config_path('mycroft'),
|
||||||
|
'mycroft.conf')
|
||||||
|
|
||||||
REMOTE_CONFIG = "mycroft.ai"
|
REMOTE_CONFIG = "mycroft.ai"
|
||||||
WEB_CONFIG_CACHE = os.environ.get('MYCROFT_WEB_CACHE',
|
WEB_CONFIG_CACHE = os.environ.get('MYCROFT_WEB_CACHE',
|
||||||
'/var/tmp/mycroft_web_cache.json')
|
'/var/tmp/mycroft_web_cache.json')
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// overridden at the REMOTE level (set by the user via
|
// overridden at the REMOTE level (set by the user via
|
||||||
// https://home.mycroft.ai), at the SYSTEM level (typically in the file
|
// https://home.mycroft.ai), at the SYSTEM level (typically in the file
|
||||||
// '/etc/mycroft/mycroft.conf'), or at the USER level (typically in the
|
// '/etc/mycroft/mycroft.conf'), or at the USER level (typically in the
|
||||||
// file '~/.mycroft/mycroft.conf').
|
// file '~/.config/mycroft/mycroft.conf').
|
||||||
//
|
//
|
||||||
// The load order of settings is:
|
// The load order of settings is:
|
||||||
// DEFAULT
|
// DEFAULT
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
},
|
},
|
||||||
"upload_skill_manifest": true,
|
"upload_skill_manifest": true,
|
||||||
// Directory to look for user skills
|
// Directory to look for user skills
|
||||||
"directory": "~/.mycroft/skills",
|
"directory": "~/.local/share/mycroft/skills",
|
||||||
// Enable auto update by msm
|
// Enable auto update by msm
|
||||||
"auto_update": true,
|
"auto_update": true,
|
||||||
// blacklisted skills to not load
|
// blacklisted skills to not load
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
"threshold": 1e-90,
|
"threshold": 1e-90,
|
||||||
"lang": "en-us"
|
"lang": "en-us"
|
||||||
// Specify custom model via:
|
// Specify custom model via:
|
||||||
// "local_model_file": "~/.mycroft/precise/models/something.pb"
|
// "local_model_file": "~/.local/share/mycroft/precise/models/something.pb"
|
||||||
// Precise options:
|
// Precise options:
|
||||||
// "sensitivity": 0.5, // Higher = more sensitive
|
// "sensitivity": 0.5, // Higher = more sensitive
|
||||||
// "trigger_level": 3 // Higher = more delay & less sensitive
|
// "trigger_level": 3 // Higher = more delay & less sensitive
|
||||||
|
@ -325,7 +325,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"padatious": {
|
"padatious": {
|
||||||
"intent_cache": "~/.mycroft/intent_cache",
|
"intent_cache": "~/.local/share/mycroft/intent_cache",
|
||||||
"train_delay": 4,
|
"train_delay": 4,
|
||||||
"single_thread": false
|
"single_thread": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
from os.path import join, expanduser, isdir
|
from os.path import join, expanduser, isdir
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
|
|
||||||
class FileSystemAccess:
|
class FileSystemAccess:
|
||||||
|
@ -31,7 +33,16 @@ class FileSystemAccess:
|
||||||
def __init_path(path):
|
def __init_path(path):
|
||||||
if not isinstance(path, str) or len(path) == 0:
|
if not isinstance(path, str) or len(path) == 0:
|
||||||
raise ValueError("path must be initialized as a non empty string")
|
raise ValueError("path must be initialized as a non empty string")
|
||||||
path = join(expanduser('~'), '.mycroft', path)
|
|
||||||
|
old_path = join(expanduser('~'), '.mycroft', path)
|
||||||
|
path = join(xdg.BaseDirectory.save_config_path('mycroft'), path)
|
||||||
|
|
||||||
|
# Migrate from the old location if it still exists
|
||||||
|
# TODO: remove in 22.02
|
||||||
|
if isdir(old_path):
|
||||||
|
if isdir(path):
|
||||||
|
shutil.rmtree(path)
|
||||||
|
shutil.move(old_path, path)
|
||||||
|
|
||||||
if not isdir(path):
|
if not isdir(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
from websocket import create_connection
|
from websocket import create_connection
|
||||||
|
|
||||||
from mycroft.configuration import Configuration
|
from mycroft.configuration import Configuration
|
||||||
from mycroft.configuration.locations import (DEFAULT_CONFIG, SYSTEM_CONFIG,
|
|
||||||
USER_CONFIG)
|
|
||||||
from mycroft.messagebus.client import MessageBusClient
|
from mycroft.messagebus.client import MessageBusClient
|
||||||
from mycroft.messagebus.message import Message
|
from mycroft.messagebus.message import Message
|
||||||
|
|
||||||
|
@ -32,10 +30,7 @@ def send(message_to_send, data_to_send=None):
|
||||||
data_to_send = data_to_send or {}
|
data_to_send = data_to_send or {}
|
||||||
|
|
||||||
# Calculate the standard Mycroft messagebus websocket address
|
# Calculate the standard Mycroft messagebus websocket address
|
||||||
config = Configuration.get([DEFAULT_CONFIG,
|
config = Configuration.get(cache=False, remote=False)
|
||||||
SYSTEM_CONFIG,
|
|
||||||
USER_CONFIG],
|
|
||||||
cache=False)
|
|
||||||
config = config.get("websocket")
|
config = config.get("websocket")
|
||||||
url = MessageBusClient.build_url(
|
url = MessageBusClient.build_url(
|
||||||
config.get("host"),
|
config.get("host"),
|
||||||
|
|
|
@ -20,6 +20,7 @@ These classes, decorators and functions are used to build skills for Mycroft.
|
||||||
|
|
||||||
from .mycroft_skill import (MycroftSkill, intent_handler, intent_file_handler,
|
from .mycroft_skill import (MycroftSkill, intent_handler, intent_file_handler,
|
||||||
resting_screen_handler, skill_api_method)
|
resting_screen_handler, skill_api_method)
|
||||||
|
from .intent_service import AdaptIntent
|
||||||
from .fallback_skill import FallbackSkill
|
from .fallback_skill import FallbackSkill
|
||||||
from .common_iot_skill import CommonIoTSkill
|
from .common_iot_skill import CommonIoTSkill
|
||||||
from .common_play_skill import CommonPlaySkill, CPSMatchLevel
|
from .common_play_skill import CommonPlaySkill, CPSMatchLevel
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
times.
|
times.
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
import shutil
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from os.path import isfile, join, expanduser
|
from os.path import isfile, join, expanduser
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
from mycroft.configuration import Configuration
|
from mycroft.configuration import Configuration
|
||||||
from mycroft.messagebus.message import Message
|
from mycroft.messagebus.message import Message
|
||||||
|
@ -54,14 +56,20 @@ class EventScheduler(Thread):
|
||||||
"""
|
"""
|
||||||
def __init__(self, bus, schedule_file='schedule.json'):
|
def __init__(self, bus, schedule_file='schedule.json'):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
data_dir = expanduser(Configuration.get()['data_dir'])
|
|
||||||
|
|
||||||
self.events = {}
|
self.events = {}
|
||||||
self.event_lock = Lock()
|
self.event_lock = Lock()
|
||||||
|
|
||||||
self.bus = bus
|
self.bus = bus
|
||||||
self.is_running = True
|
self.is_running = True
|
||||||
self.schedule_file = join(data_dir, schedule_file)
|
old_schedule_path = join(expanduser(Configuration.get()['data_dir']),
|
||||||
|
schedule_file)
|
||||||
|
new_schedule_path = join(
|
||||||
|
xdg.BaseDirectory.load_first_config('mycroft'), schedule_file
|
||||||
|
)
|
||||||
|
if isfile(old_schedule_path):
|
||||||
|
shutil.move(old_schedule_path, new_schedule_path)
|
||||||
|
self.schedule_file = new_schedule_path
|
||||||
if self.schedule_file:
|
if self.schedule_file:
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import time
|
from time import time
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
from msm import MsmException
|
from msm import MsmException
|
||||||
|
|
||||||
|
@ -97,9 +98,9 @@ class SkillUpdater:
|
||||||
'.mycroft-skills'
|
'.mycroft-skills'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self._installed_skills_file_path = os.path.expanduser(
|
self._installed_skills_file_path = os.path.join(
|
||||||
'~/.mycroft/.mycroft-skills'
|
xdg.BaseDirectory.save_data_path('mycroft'),
|
||||||
)
|
'.mycroft-skills')
|
||||||
|
|
||||||
return self._installed_skills_file_path
|
return self._installed_skills_file_path
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import os
|
||||||
import psutil
|
import psutil
|
||||||
from stat import S_ISREG, ST_MTIME, ST_MODE, ST_SIZE
|
from stat import S_ISREG, ST_MTIME, ST_MODE, ST_SIZE
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import xdg.BaseDirectory
|
||||||
|
|
||||||
import mycroft.configuration
|
import mycroft.configuration
|
||||||
from .log import LOG
|
from .log import LOG
|
||||||
|
@ -33,15 +34,16 @@ def resolve_resource_file(res_name):
|
||||||
Resource names are in the form: 'filename.ext'
|
Resource names are in the form: 'filename.ext'
|
||||||
or 'path/filename.ext'
|
or 'path/filename.ext'
|
||||||
|
|
||||||
The system wil look for ~/.mycroft/res_name first, and
|
The system wil look for $XDG_DATA_DIRS/mycroft/res_name first
|
||||||
if not found will look at /opt/mycroft/res_name,
|
(defaults to ~/.local/share/mycroft/res_name), and if not found will
|
||||||
then finally it will look for res_name in the 'mycroft/res'
|
look at /opt/mycroft/res_name, then finally it will look for res_name
|
||||||
folder of the source code package.
|
in the 'mycroft/res' folder of the source code package.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
With mycroft running as the user 'bob', if you called
|
With mycroft running as the user 'bob', if you called
|
||||||
``resolve_resource_file('snd/beep.wav')``
|
``resolve_resource_file('snd/beep.wav')``
|
||||||
it would return either:
|
it would return either:
|
||||||
|
'$XDG_DATA_DIRS/mycroft/beep.wav',
|
||||||
'/home/bob/.mycroft/snd/beep.wav' or
|
'/home/bob/.mycroft/snd/beep.wav' or
|
||||||
'/opt/mycroft/snd/beep.wav' or
|
'/opt/mycroft/snd/beep.wav' or
|
||||||
'.../mycroft/res/snd/beep.wav'
|
'.../mycroft/res/snd/beep.wav'
|
||||||
|
@ -60,8 +62,14 @@ def resolve_resource_file(res_name):
|
||||||
if os.path.isfile(res_name):
|
if os.path.isfile(res_name):
|
||||||
return res_name
|
return res_name
|
||||||
|
|
||||||
# Now look for ~/.mycroft/res_name (in user folder)
|
# Now look for XDG_DATA_DIRS
|
||||||
filename = os.path.expanduser("~/.mycroft/" + res_name)
|
for conf_dir in xdg.BaseDirectory.load_data_paths('mycroft'):
|
||||||
|
filename = os.path.join(conf_dir, res_name)
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
return filename
|
||||||
|
|
||||||
|
# Now look in the old user location
|
||||||
|
filename = os.path.join(os.path.expanduser('~'), '.mycroft', res_name)
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ This module provides the LOG pseudo function quickly creating a logger instance
|
||||||
for use.
|
for use.
|
||||||
|
|
||||||
The default log level of the logger created here can ONLY be set in
|
The default log level of the logger created here can ONLY be set in
|
||||||
/etc/mycroft/mycroft.conf or ~/.mycroft/mycroft.conf
|
/etc/mycroft/mycroft.conf or ~/.config/mycroft/mycroft.conf
|
||||||
|
|
||||||
The default log level can also be programatically be changed by setting the
|
The default log level can also be programatically be changed by setting the
|
||||||
LOG.level parameter.
|
LOG.level parameter.
|
||||||
|
@ -31,10 +31,7 @@ import inspect
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from os.path import isfile
|
import mycroft
|
||||||
|
|
||||||
from mycroft.util.json_helper import load_commented_json, merge_dict
|
|
||||||
from mycroft.configuration.locations import SYSTEM_CONFIG, USER_CONFIG
|
|
||||||
|
|
||||||
|
|
||||||
def getLogger(name="MYCROFT"):
|
def getLogger(name="MYCROFT"):
|
||||||
|
@ -65,7 +62,7 @@ class LOG:
|
||||||
|
|
||||||
_custom_name = None
|
_custom_name = None
|
||||||
handler = None
|
handler = None
|
||||||
level = None
|
level = logging.getLevelName('INFO')
|
||||||
|
|
||||||
# Copy actual logging methods from logging.Logger
|
# Copy actual logging methods from logging.Logger
|
||||||
# Usage: LOG.debug(message)
|
# Usage: LOG.debug(message)
|
||||||
|
@ -80,20 +77,6 @@ class LOG:
|
||||||
""" Initializes the class, sets the default log level and creates
|
""" Initializes the class, sets the default log level and creates
|
||||||
the required handlers.
|
the required handlers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Check configs manually, the Mycroft configuration system can't be
|
|
||||||
# used since it uses the LOG system and would cause horrible cyclic
|
|
||||||
# dependencies.
|
|
||||||
confs = [SYSTEM_CONFIG, USER_CONFIG]
|
|
||||||
config = {}
|
|
||||||
for conf in confs:
|
|
||||||
try:
|
|
||||||
merge_dict(config,
|
|
||||||
load_commented_json(conf) if isfile(conf) else {})
|
|
||||||
except Exception as e:
|
|
||||||
print('couldn\'t load {}: {}'.format(conf, str(e)))
|
|
||||||
|
|
||||||
cls.level = logging.getLevelName(config.get('log_level', 'INFO'))
|
|
||||||
log_message_format = (
|
log_message_format = (
|
||||||
'{asctime} | {levelname:8} | {process:5} | {name} | {message}'
|
'{asctime} | {levelname:8} | {process:5} | {name} | {message}'
|
||||||
)
|
)
|
||||||
|
@ -103,6 +86,9 @@ class LOG:
|
||||||
cls.handler = logging.StreamHandler(sys.stdout)
|
cls.handler = logging.StreamHandler(sys.stdout)
|
||||||
cls.handler.setFormatter(formatter)
|
cls.handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
config = mycroft.configuration.Configuration.get(remote=False)
|
||||||
|
cls.level = logging.getLevelName(config.get('log_level', 'INFO'))
|
||||||
|
|
||||||
# Enable logging in external modules
|
# Enable logging in external modules
|
||||||
cls.create_logger('').setLevel(cls.level)
|
cls.create_logger('').setLevel(cls.level)
|
||||||
|
|
||||||
|
@ -144,6 +130,3 @@ class LOG:
|
||||||
name = 'Mycroft'
|
name = 'Mycroft'
|
||||||
|
|
||||||
func(cls.create_logger(name), *args, **kwargs)
|
func(cls.create_logger(name), *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
LOG.init()
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ from mycroft.util.log import LOG
|
||||||
# START_VERSION_BLOCK
|
# START_VERSION_BLOCK
|
||||||
CORE_VERSION_MAJOR = 21
|
CORE_VERSION_MAJOR = 21
|
||||||
CORE_VERSION_MINOR = 2
|
CORE_VERSION_MINOR = 2
|
||||||
CORE_VERSION_BUILD = 0
|
CORE_VERSION_BUILD = 1
|
||||||
# END_VERSION_BLOCK
|
# END_VERSION_BLOCK
|
||||||
|
|
||||||
CORE_VERSION_TUPLE = (CORE_VERSION_MAJOR,
|
CORE_VERSION_TUPLE = (CORE_VERSION_MAJOR,
|
||||||
|
|
|
@ -88,10 +88,10 @@ function restore_init_scripts() {
|
||||||
sudo sh -c 'cat /etc/init.d/mycroft-admin-service.original > /etc/init.d/mycroft-admin-service'
|
sudo sh -c 'cat /etc/init.d/mycroft-admin-service.original > /etc/init.d/mycroft-admin-service'
|
||||||
sudo rm /etc/init.d/*.original
|
sudo rm /etc/init.d/*.original
|
||||||
chown mycroft:mycroft /home/mycroft/.mycroft/identity/identity2.json
|
chown mycroft:mycroft /home/mycroft/.mycroft/identity/identity2.json
|
||||||
sudo chown -Rvf mycroft:mycroft /var/log/mycroft*
|
sudo chown -R mycroft:mycroft /var/log/mycroft*
|
||||||
sudo chown -Rvf mycroft:mycroft /tmp/mycroft
|
sudo chown -R mycroft:mycroft /tmp/mycroft
|
||||||
sudo chown -Rvf mycroft:mycroft /var/run/mycroft*
|
sudo chown -R mycroft:mycroft /var/run/mycroft*
|
||||||
sudo chown -Rvf mycroft:mycroft /opt/mycroft
|
sudo chown -R mycroft:mycroft /opt/mycroft
|
||||||
sudo chown mycroft:mycroft /var/tmp/mycroft_web_cache.json
|
sudo chown mycroft:mycroft /var/tmp/mycroft_web_cache.json
|
||||||
|
|
||||||
# reload daemon scripts
|
# reload daemon scripts
|
||||||
|
@ -144,10 +144,10 @@ function github_init_scripts() {
|
||||||
sudo ln -s /home/mycroft/.mycroft/identity ${HOME}/.mycroft/
|
sudo ln -s /home/mycroft/.mycroft/identity ${HOME}/.mycroft/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo chown -Rvf ${user}:${user} /var/log/mycroft*
|
sudo chown -R ${user}:${user} /var/log/mycroft*
|
||||||
sudo chown -Rvf ${user}:${user} /var/run/mycroft*
|
sudo chown -R ${user}:${user} /var/run/mycroft*
|
||||||
sudo chown -Rvf ${user}:${user} /tmp/mycroft
|
sudo chown -R ${user}:${user} /tmp/mycroft
|
||||||
sudo chown -Rvf ${user}:${user} /var/tmp/mycroft_web_cache.json
|
sudo chown -R ${user}:${user} /var/tmp/mycroft_web_cache.json
|
||||||
|
|
||||||
# reload daemon scripts
|
# reload daemon scripts
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|
|
@ -96,7 +96,7 @@ FROM core_builder as voight_kampff_builder
|
||||||
ARG platform
|
ARG platform
|
||||||
# Setup a dummy TTS backend for the audio process
|
# Setup a dummy TTS backend for the audio process
|
||||||
RUN mkdir /etc/mycroft
|
RUN mkdir /etc/mycroft
|
||||||
RUN echo '{"tts": {"module": "dummy"}}' > /etc/mycroft/mycroft.conf
|
RUN echo '{"tts": {"module": "dummy"}, "skills": {"auto_update": false}}' > /etc/mycroft/mycroft.conf
|
||||||
RUN mkdir ~/.mycroft/allure-result
|
RUN mkdir ~/.mycroft/allure-result
|
||||||
|
|
||||||
# The behave feature files for a skill are defined within the skill's
|
# The behave feature files for a skill are defined within the skill's
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
"""Unit tests for the SkillUpdater class."""
|
"""Unit tests for the SkillUpdater class."""
|
||||||
from os import path
|
import os
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from xdg import BaseDirectory
|
||||||
from unittest.mock import Mock, patch, PropertyMock
|
from unittest.mock import Mock, patch, PropertyMock
|
||||||
|
|
||||||
from mycroft.skills.skill_updater import SkillUpdater
|
from mycroft.skills.skill_updater import SkillUpdater
|
||||||
|
@ -143,7 +144,8 @@ class TestSkillUpdater(MycroftUnitTestBase):
|
||||||
os_patch.return_value = False
|
os_patch.return_value = False
|
||||||
updater = SkillUpdater(self.message_bus_mock)
|
updater = SkillUpdater(self.message_bus_mock)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
path.expanduser('~/.mycroft/.mycroft-skills'),
|
os.path.join(BaseDirectory.save_data_path('mycroft'),
|
||||||
|
'.mycroft-skills'),
|
||||||
updater.installed_skills_file_path
|
updater.installed_skills_file_path
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"skills": {
|
"skills": {
|
||||||
"directory": "~/.mycroft/skills"
|
"directory": "~/.local/share/mycroft/skills"
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
"url": "https://api.mycroft.ai",
|
"url": "https://api.mycroft.ai",
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"skills": {
|
"skills": {
|
||||||
"directory": "~/.mycroft/skills"
|
"directory": "~/.local/share/mycroft/skills"
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
"url": "https://api.mycroft.ai",
|
"url": "https://api.mycroft.ai",
|
||||||
|
|
Loading…
Reference in New Issue