Commit 3b6021cb authored by Bart Ribbers's avatar Bart Ribbers Committed by TBK
Browse files

community/mycroft-core: fix first XDG patch

It seems I added an old patch first. This is the correct one, fixes an
issue where the installed skills file would be a directory instead
parent 91c8694f
Pipeline #68723 passed with stages
in 2 minutes and 20 seconds
From ed3d54c8f15de72c8287fb1c57138e7c1de4073c Mon Sep 17 00:00:00 2001
From e1397d10abb4d1e6d45f5eeacd550efe6b5737ef Mon Sep 17 00:00:00 2001
From: Bart Ribbers <bribbers@disroot.org>
Date: Fri, 8 May 2020 21:32:33 +0200
Subject: [PATCH 1/3] Use XDG Base directories for settings, cache and runtime
data
Subject: [PATCH] Use XDG Base directories for settings, cache and runtime data
---
README.md | 10 +--
......@@ -18,8 +17,8 @@ Subject: [PATCH 1/3] Use XDG Base directories for settings, cache and runtime
mycroft/configuration/mycroft.conf | 8 +--
mycroft/filesystem/__init__.py | 10 ++-
mycroft/messagebus/send_func.py | 7 +--
mycroft/skills/event_scheduler.py | 10 ++-
mycroft/skills/skill_updater.py | 7 ++-
mycroft/skills/event_scheduler.py | 11 +++-
mycroft/skills/skill_updater.py | 6 +-
mycroft/util/file_utils.py | 21 ++++---
mycroft/util/log.py | 11 ++--
test/unittests/skills/test_skill_updater.py | 6 +-
......@@ -28,7 +27,7 @@ Subject: [PATCH 1/3] Use XDG Base directories for settings, cache and runtime
20 files changed, 212 insertions(+), 92 deletions(-)
diff --git a/README.md b/README.md
index 1665b0a68dd..eaf04259ddb 100644
index 1665b0a68d..eaf04259dd 100644
--- a/README.md
+++ b/README.md
@@ -71,20 +71,20 @@ Mycroft is nothing without skills. There are a handful of default skills that a
......@@ -58,7 +57,7 @@ index 1665b0a68dd..eaf04259ddb 100644
```
{
diff --git a/bin/mycroft-config b/bin/mycroft-config
index a1271b328df..981f2c5d0c6 100755
index a1271b328d..981f2c5d0c 100755
--- a/bin/mycroft-config
+++ b/bin/mycroft-config
@@ -95,13 +95,13 @@ function validate_config_file() {
......@@ -79,10 +78,10 @@ index a1271b328df..981f2c5d0c6 100755
*)
echo "ERROR: Unknown name '${1}'."
diff --git a/mycroft/api/__init__.py b/mycroft/api/__init__.py
index 43663ee1270..d2843120ef4 100644
index 43663ee127..d2843120ef 100644
--- a/mycroft/api/__init__.py
+++ b/mycroft/api/__init__.py
@@ -20,8 +20,6 @@
@@ -20,8 +20,6 @@ import requests
from requests import HTTPError, RequestException
from mycroft.configuration import Configuration
......@@ -106,7 +105,7 @@ index 43663ee1270..d2843120ef4 100644
config_server = config.get("server")
self.url = config_server.get("url")
self.version = config_server.get("version")
@@ -238,9 +233,7 @@ def activate(self, state, token):
@@ -238,9 +233,7 @@ class DeviceApi(Api):
platform_build = ""
# load just the local configs to get platform info
......@@ -117,7 +116,7 @@ index 43663ee1270..d2843120ef4 100644
if "enclosure" in config:
platform = config.get("enclosure").get("platform", "unknown")
platform_build = config.get("enclosure").get("platform_build", "")
@@ -262,9 +255,7 @@ def update_version(self):
@@ -262,9 +255,7 @@ class DeviceApi(Api):
platform_build = ""
# load just the local configs to get platform info
......@@ -129,7 +128,7 @@ index 43663ee1270..d2843120ef4 100644
platform = config.get("enclosure").get("platform", "unknown")
platform_build = config.get("enclosure").get("platform_build", "")
diff --git a/mycroft/client/enclosure/__main__.py b/mycroft/client/enclosure/__main__.py
index 7ff403f4175..074258e0d9b 100644
index 7ff403f417..074258e0d9 100644
--- a/mycroft/client/enclosure/__main__.py
+++ b/mycroft/client/enclosure/__main__.py
@@ -17,7 +17,7 @@
......@@ -153,7 +152,7 @@ index 7ff403f4175..074258e0d9b 100644
enclosure = create_enclosure(platform)
if enclosure:
diff --git a/mycroft/client/enclosure/mark1/__init__.py b/mycroft/client/enclosure/mark1/__init__.py
index 26a7311c791..491d096496c 100644
index 26a7311c79..491d096496 100644
--- a/mycroft/client/enclosure/mark1/__init__.py
+++ b/mycroft/client/enclosure/mark1/__init__.py
@@ -15,8 +15,10 @@
......@@ -167,7 +166,7 @@ index 26a7311c791..491d096496c 100644
import serial
@@ -163,6 +165,9 @@ def process(self, data):
@@ -163,6 +165,9 @@ class EnclosureReader(Thread):
if "unit.factory-reset" in data:
self.bus.emit(Message("speak", {
'utterance': mycroft.dialog.get("reset to factory defaults")}))
......@@ -178,10 +177,10 @@ index 26a7311c791..491d096496c 100644
'rm ~/.mycroft/identity/identity2.json',
shell=True)
diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py
index 6573b7aac40..4938c9dbb87 100644
index 6573b7aac4..4938c9dbb8 100644
--- a/mycroft/client/speech/hotword_factory.py
+++ b/mycroft/client/speech/hotword_factory.py
@@ -28,10 +28,12 @@
@@ -28,10 +28,12 @@ from os.path import dirname, exists, join, abspath, expanduser, isfile, isdir
from shutil import rmtree
from threading import Timer, Thread
from urllib.error import HTTPError
......@@ -195,7 +194,7 @@ index 6573b7aac40..4938c9dbb87 100644
from mycroft.util.log import LOG
from mycroft.util.monotonic_event import MonotonicEvent
from mycroft.util.plugins import load_plugin
@@ -191,7 +193,27 @@ def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
@@ -191,7 +193,27 @@ class PreciseHotword(HotWordEngine):
from precise_runner import (
PreciseRunner, PreciseEngine, ReadWriteStream
)
......@@ -224,7 +223,7 @@ index 6573b7aac40..4938c9dbb87 100644
if (local_conf.get('precise', {}).get('dist_url') ==
'http://bootstrap.mycroft.ai/artifacts/static/daily/'):
del local_conf['precise']['dist_url']
@@ -249,7 +271,10 @@ def update_precise(self, precise_config):
@@ -249,7 +271,10 @@ class PreciseHotword(HotWordEngine):
@property
def folder(self):
......@@ -236,7 +235,7 @@ index 6573b7aac40..4938c9dbb87 100644
@property
def install_destination(self):
@@ -359,8 +384,23 @@ def found_wake_word(self, frame_data):
@@ -359,8 +384,23 @@ class SnowboyHotWord(HotWordEngine):
class PorcupineHotWord(HotWordEngine):
def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
super(PorcupineHotWord, self).__init__(key_phrase, config, lang)
......@@ -262,7 +261,7 @@ index 6573b7aac40..4938c9dbb87 100644
"keyword_file_path", "hey_mycroft.ppn").split(',')]
sensitivities = self.config.get("sensitivities", 0.5)
diff --git a/mycroft/client/text/text_client.py b/mycroft/client/text/text_client.py
index 0c841d71a87..3729f153f26 100644
index 0c841d71a8..3729f153f2 100644
--- a/mycroft/client/text/text_client.py
+++ b/mycroft/client/text/text_client.py
@@ -15,6 +15,7 @@
......@@ -329,7 +328,7 @@ index 0c841d71a87..3729f153f26 100644
f.write(str(json.dumps(config, ensure_ascii=False)))
diff --git a/mycroft/configuration/__init__.py b/mycroft/configuration/__init__.py
index da28826c11d..b920d9c8336 100644
index da28826c11..b920d9c833 100644
--- a/mycroft/configuration/__init__.py
+++ b/mycroft/configuration/__init__.py
@@ -13,4 +13,3 @@
......@@ -338,7 +337,7 @@ index da28826c11d..b920d9c8336 100644
from .config import Configuration, LocalConf, RemoteConf
-from .locations import SYSTEM_CONFIG, USER_CONFIG
diff --git a/mycroft/configuration/config.py b/mycroft/configuration/config.py
index dd82eae651f..d5a9fd520a4 100644
index dd82eae651..d5a9fd520a 100644
--- a/mycroft/configuration/config.py
+++ b/mycroft/configuration/config.py
@@ -17,15 +17,15 @@
......@@ -380,7 +379,7 @@ index dd82eae651f..d5a9fd520a4 100644
"""Get configuration
Returns cached instance if available otherwise builds a new
@@ -182,6 +183,9 @@ def get(configs=None, cache=True):
@@ -182,6 +183,9 @@ class Configuration:
Arguments:
configs (list): List of configuration dicts
cache (boolean): True if the result should be cached
......@@ -390,7 +389,7 @@ index dd82eae651f..d5a9fd520a4 100644
Returns:
(dict) configuration dictionary.
@@ -189,23 +193,62 @@ def get(configs=None, cache=True):
@@ -189,23 +193,62 @@ class Configuration:
if Configuration.__config:
return Configuration.__config
else:
......@@ -460,7 +459,7 @@ index dd82eae651f..d5a9fd520a4 100644
# Handle strings in stack
for index, item in enumerate(configs):
diff --git a/mycroft/configuration/locations.py b/mycroft/configuration/locations.py
index cbbaab6ca94..eb8cfb18c76 100644
index cbbaab6ca9..eb8cfb18c7 100644
--- a/mycroft/configuration/locations.py
+++ b/mycroft/configuration/locations.py
@@ -13,26 +13,13 @@
......@@ -497,7 +496,7 @@ index cbbaab6ca94..eb8cfb18c76 100644
+USER_CONFIG = join(BaseDirectory.save_config_path('mycroft'),
+ 'mycroft.conf')
diff --git a/mycroft/configuration/mycroft.conf b/mycroft/configuration/mycroft.conf
index b18eb9b09a9..c61fd90579b 100644
index b18eb9b09a..c61fd90579 100644
--- a/mycroft/configuration/mycroft.conf
+++ b/mycroft/configuration/mycroft.conf
@@ -5,7 +5,7 @@
......@@ -537,7 +536,7 @@ index b18eb9b09a9..c61fd90579b 100644
"single_thread": false
},
diff --git a/mycroft/filesystem/__init__.py b/mycroft/filesystem/__init__.py
index 45ec15a4ac5..ecd10d86e41 100644
index 45ec15a4ac..ecd10d86e4 100644
--- a/mycroft/filesystem/__init__.py
+++ b/mycroft/filesystem/__init__.py
@@ -13,7 +13,9 @@
......@@ -550,7 +549,7 @@ index 45ec15a4ac5..ecd10d86e41 100644
class FileSystemAccess:
@@ -30,7 +32,13 @@ def __init__(self, path):
@@ -30,7 +32,13 @@ class FileSystemAccess:
def __init_path(path):
if not isinstance(path, str) or len(path) == 0:
raise ValueError("path must be initialized as a non empty string")
......@@ -566,7 +565,7 @@ index 45ec15a4ac5..ecd10d86e41 100644
if not isdir(path):
os.makedirs(path)
diff --git a/mycroft/messagebus/send_func.py b/mycroft/messagebus/send_func.py
index 403db9f45c1..a11a9b0a591 100644
index 403db9f45c..a11a9b0a59 100644
--- a/mycroft/messagebus/send_func.py
+++ b/mycroft/messagebus/send_func.py
@@ -15,8 +15,6 @@
......@@ -591,10 +590,15 @@ index 403db9f45c1..a11a9b0a591 100644
url = MessageBusClient.build_url(
config.get("host"),
diff --git a/mycroft/skills/event_scheduler.py b/mycroft/skills/event_scheduler.py
index fe41ac1bedc..5412dd02548 100644
index fe41ac1bed..f9931a7ea1 100644
--- a/mycroft/skills/event_scheduler.py
+++ b/mycroft/skills/event_scheduler.py
@@ -20,6 +20,7 @@
@@ -16,10 +16,12 @@
times.
"""
import json
+import shutil
import time
from datetime import datetime, timedelta
from threading import Thread, Lock
from os.path import isfile, join, expanduser
......@@ -602,7 +606,7 @@ index fe41ac1bedc..5412dd02548 100644
from mycroft.configuration import Configuration
from mycroft.messagebus.message import Message
@@ -54,14 +55,19 @@ class EventScheduler(Thread):
@@ -54,14 +56,19 @@ class EventScheduler(Thread):
"""
def __init__(self, bus, schedule_file='schedule.json'):
super().__init__()
......@@ -615,20 +619,20 @@ index fe41ac1bedc..5412dd02548 100644
self.is_running = True
- self.schedule_file = join(data_dir, schedule_file)
+ old_schedule_path = join(expanduser(Configuration.get()['data_dir']),
+ schedule_file)
+ schedule_file)
+ new_schedule_path = join(
+ BaseDirectory.load_first_config('mycroft'), schedule_file)
+ if isfile(old_schedule_path):
+ shutil.move(old_schedule_path, new_schedule_path)
+ self.schedule_file = new_path
+ self.schedule_file = new_schedule_path
if self.schedule_file:
self.load()
diff --git a/mycroft/skills/skill_updater.py b/mycroft/skills/skill_updater.py
index ace247e2db4..37f4bdc72eb 100644
index ace247e2db..2fa2ab6834 100644
--- a/mycroft/skills/skill_updater.py
+++ b/mycroft/skills/skill_updater.py
@@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@ import os
import sys
from datetime import datetime
from time import time
......@@ -636,7 +640,7 @@ index ace247e2db4..37f4bdc72eb 100644
from msm import MsmException
@@ -96,9 +97,9 @@ def installed_skills_file_path(self):
@@ -96,9 +97,8 @@ class SkillUpdater:
'.mycroft-skills'
)
else:
......@@ -644,16 +648,15 @@ index ace247e2db4..37f4bdc72eb 100644
- '~/.mycroft/.mycroft-skills'
- )
+ self._installed_skills_file_path = os.path.join(
+ BaseDirectory.save_data_path('mycroft',
+ 'skills'))
+ BaseDirectory.save_data_path('mycroft'), '.mycroft-skills')
return self._installed_skills_file_path
diff --git a/mycroft/util/file_utils.py b/mycroft/util/file_utils.py
index 84555fc3bb3..7c09fd226ee 100644
index 84555fc3bb..7c09fd226e 100644
--- a/mycroft/util/file_utils.py
+++ b/mycroft/util/file_utils.py
@@ -22,6 +22,7 @@
@@ -22,6 +22,7 @@ import os
import psutil
from stat import S_ISREG, ST_MTIME, ST_MODE, ST_SIZE
import tempfile
......@@ -700,10 +703,10 @@ index 84555fc3bb3..7c09fd226ee 100644
return filename
diff --git a/mycroft/util/log.py b/mycroft/util/log.py
index 0ea391f8f79..788f6df1c37 100644
index 0ea391f8f7..788f6df1c3 100644
--- a/mycroft/util/log.py
+++ b/mycroft/util/log.py
@@ -21,7 +21,7 @@
@@ -21,7 +21,7 @@ This module provides the LOG pseudo function quickly creating a logger instance
for use.
The default log level of the logger created here can ONLY be set in
......@@ -712,7 +715,7 @@ index 0ea391f8f79..788f6df1c37 100644
The default log level can also be programatically be changed by setting the
LOG.level parameter.
@@ -31,10 +31,10 @@
@@ -31,10 +31,10 @@ import inspect
import logging
import sys
......@@ -725,7 +728,7 @@ index 0ea391f8f79..788f6df1c37 100644
def getLogger(name="MYCROFT"):
@@ -84,7 +84,10 @@ def init(cls):
@@ -84,7 +84,10 @@ class LOG:
# Check configs manually, the Mycroft configuration system can't be
# used since it uses the LOG system and would cause horrible cyclic
# dependencies.
......@@ -738,7 +741,7 @@ index 0ea391f8f79..788f6df1c37 100644
for conf in confs:
try:
diff --git a/test/unittests/skills/test_skill_updater.py b/test/unittests/skills/test_skill_updater.py
index 38d4083d7f2..fbcc9254319 100644
index 38d4083d7f..d7cc72e3e6 100644
--- a/test/unittests/skills/test_skill_updater.py
+++ b/test/unittests/skills/test_skill_updater.py
@@ -13,8 +13,9 @@
......@@ -752,18 +755,18 @@ index 38d4083d7f2..fbcc9254319 100644
from unittest.mock import Mock, patch, PropertyMock
from mycroft.skills.skill_updater import SkillUpdater
@@ -143,7 +144,8 @@ def test_installed_skills_path_not_virtual_env(self):
@@ -143,7 +144,8 @@ class TestSkillUpdater(MycroftUnitTestBase):
os_patch.return_value = False
updater = SkillUpdater(self.message_bus_mock)
self.assertEqual(
- path.expanduser('~/.mycroft/.mycroft-skills'),
+ os.path.join(BaseDirectory.save_data_path('mycroft'),
+ 'skills'),
+ '.mycroft-skills'),
updater.installed_skills_file_path
)
diff --git a/test/unittests/util/commented.json b/test/unittests/util/commented.json
index 87c7d3e2c2d..00a581f6df4 100644
index 87c7d3e2c2..00a581f6df 100644
--- a/test/unittests/util/commented.json
+++ b/test/unittests/util/commented.json
@@ -54,7 +54,7 @@
......@@ -776,7 +779,7 @@ index 87c7d3e2c2d..00a581f6df4 100644
"server": {
"url": "https://api.mycroft.ai",
diff --git a/test/unittests/util/plain.json b/test/unittests/util/plain.json
index f8c474139ce..eec84631d88 100644
index f8c474139c..eec84631d8 100644
--- a/test/unittests/util/plain.json
+++ b/test/unittests/util/plain.json
@@ -36,7 +36,7 @@
......@@ -788,43 +791,6 @@ index f8c474139ce..eec84631d88 100644
},
"server": {
"url": "https://api.mycroft.ai",
--
2.30.0
From f01c21e7680846882ae4fa0b328ffe0dea5cb89d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Forslund?= <ake.forslund@gmail.com>
Date: Fri, 15 Jan 2021 17:11:33 +0100
Subject: [PATCH 3/3] Fix issues found by flake
- missing import
- variable name typo
- line-continuation issue
---
mycroft/skills/event_scheduler.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mycroft/skills/event_scheduler.py b/mycroft/skills/event_scheduler.py
index 5412dd02548..f9931a7ea13 100644
--- a/mycroft/skills/event_scheduler.py
+++ b/mycroft/skills/event_scheduler.py
@@ -16,6 +16,7 @@
times.
"""
import json
+import shutil
import time
from datetime import datetime, timedelta
from threading import Thread, Lock
@@ -62,12 +63,12 @@ def __init__(self, bus, schedule_file='schedule.json'):
self.bus = bus
self.is_running = True
old_schedule_path = join(expanduser(Configuration.get()['data_dir']),
- schedule_file)
+ schedule_file)
new_schedule_path = join(
BaseDirectory.load_first_config('mycroft'), schedule_file)
if isfile(old_schedule_path):
shutil.move(old_schedule_path, new_schedule_path)
- self.schedule_file = new_path
+ self.schedule_file = new_schedule_path
if self.schedule_file:
self.load()
......@@ -2,7 +2,7 @@
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=mycroft-core
pkgver=20.8.0
pkgrel=5
pkgrel=6
pkgdesc="Mycroft Core, the Mycroft Artificial Intelligence platform"
url="https://mycroft.ai/"
# mips, mips64 and s390x blocked by py3-precise-runner
......@@ -85,6 +85,6 @@ package() {
}
sha512sums="5e86ee27aa9736b61f49f34ae14669ae453d0609d63443e29b8c027327f87a4495d10fec866f923862cef226da803bb55c45537d0b7bdad57c452b55acb9addc mycroft-core-20.8.0.tar.gz
c3d1a605a0b574c8e2c4031f592bdbf023f5ed9b2e1ba0cea38cf79278331f245dbe4e220e7f81de73fe612ffd722253805058dae04ba89c3d01c361b329e4ef profile.sh
9c3d4210aca3eef36fadcd112fc053ea7a26632520b63e49347cb253471afa5bbee8d34e0c942c67c7a3b65ffffbc70d316d38ae8af7f5ae52e5af3bf6e73ca4 0001-xdg-settings-cache-and-runtime-data.patch
a4554ae06b5c32371cfdfb5d5ad76c0bfee806cc5c5d6462ebe039347c10d0c66bb750330328426196f6cf203df7e9ab4cb90fcb11325ae7cf2782ca2e851fcd 0001-xdg-settings-cache-and-runtime-data.patch
861269f037c5090da03caf9782be7fabd1381e46fd3bb33b726befbbf12788b7ddc3aec08beeea23a9e7b78ca0c43286ed179746c1b715880f8447ad86c4e747 0002-system-wide-setups.patch
987c3041482a2adfa4e99228b8670f381692ace6dbf3efbedeb06c95ebcc6274b50510a19cf5f9eadb73e23344a4d1256771fc6a656748ba36dfe97767140bef 0003-skills-from-xdg.patch"
......@@ -6,6 +6,6 @@ If you want all the official MycroftAI skills, consider installing the mycroft-s
Other skills can be found by searching for "mycroft-skill-*"
To start and stop MyCroft run the following:
- /usr/bin/start-mycroft all
- /usr/bin/stop-mycroft all
- /usr/bin/mycroft-start all
- /usr/bin/mycroft
EOF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment