mycroft-core/mycroft/skills/main.py

442 lines
16 KiB
Python
Raw Normal View History

Change to Apache 2.0 license from GPLv3.0 This commit officially switches the mycroft-core repository from GPLv3.0 licensing to Apache 2.0. All dependencies on GPL'ed code have been removed and we have contacted all previous contributors with still-existing code in the repository to agree to this change. Going forward, all contributors will sign a Contributor License Agreement (CLA) by visiting https://mycroft.ai/cla, then they will be included in the Mycroft Project's overall Contributor list, found at: https://github.com/MycroftAI/contributors. This cleanly protects the project, the contributor and all who use the technology to build upon. Futher discussion can be found at this blog post: https://mycroft.ai/blog/right-license/ This commit also removes all __author__="" from the code. These lines are painful to maintain and the etiquette surrounding their maintainence is unclear. Do you remove a name from the list if the last line of code the wrote gets replaced? Etc. Now all contributors are publicly acknowledged in the aforementioned repo, and actual authorship is maintained by Github in a much more effective and elegant way! Finally, a few references to "Mycroft AI" were changed to the correct legal entity name "Mycroft AI Inc." ==== Fixed Issues ==== #403 Update License.md and file headers to Apache 2.0 #400 Update LICENSE.md ==== Documentation Notes ==== Deprecated the ScheduledSkill and ScheduledCRUDSkill classes. These capabilities have been superceded by the more flexible MycroftSkill class methods schedule_event(), schedule_repeating_event(), update_event(), and cancel_event().
2017-10-04 06:28:44 +00:00
# Copyright 2017 Mycroft AI Inc.
#
Change to Apache 2.0 license from GPLv3.0 This commit officially switches the mycroft-core repository from GPLv3.0 licensing to Apache 2.0. All dependencies on GPL'ed code have been removed and we have contacted all previous contributors with still-existing code in the repository to agree to this change. Going forward, all contributors will sign a Contributor License Agreement (CLA) by visiting https://mycroft.ai/cla, then they will be included in the Mycroft Project's overall Contributor list, found at: https://github.com/MycroftAI/contributors. This cleanly protects the project, the contributor and all who use the technology to build upon. Futher discussion can be found at this blog post: https://mycroft.ai/blog/right-license/ This commit also removes all __author__="" from the code. These lines are painful to maintain and the etiquette surrounding their maintainence is unclear. Do you remove a name from the list if the last line of code the wrote gets replaced? Etc. Now all contributors are publicly acknowledged in the aforementioned repo, and actual authorship is maintained by Github in a much more effective and elegant way! Finally, a few references to "Mycroft AI" were changed to the correct legal entity name "Mycroft AI Inc." ==== Fixed Issues ==== #403 Update License.md and file headers to Apache 2.0 #400 Update LICENSE.md ==== Documentation Notes ==== Deprecated the ScheduledSkill and ScheduledCRUDSkill classes. These capabilities have been superceded by the more flexible MycroftSkill class methods schedule_event(), schedule_repeating_event(), update_event(), and cancel_event().
2017-10-04 06:28:44 +00:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
Change to Apache 2.0 license from GPLv3.0 This commit officially switches the mycroft-core repository from GPLv3.0 licensing to Apache 2.0. All dependencies on GPL'ed code have been removed and we have contacted all previous contributors with still-existing code in the repository to agree to this change. Going forward, all contributors will sign a Contributor License Agreement (CLA) by visiting https://mycroft.ai/cla, then they will be included in the Mycroft Project's overall Contributor list, found at: https://github.com/MycroftAI/contributors. This cleanly protects the project, the contributor and all who use the technology to build upon. Futher discussion can be found at this blog post: https://mycroft.ai/blog/right-license/ This commit also removes all __author__="" from the code. These lines are painful to maintain and the etiquette surrounding their maintainence is unclear. Do you remove a name from the list if the last line of code the wrote gets replaced? Etc. Now all contributors are publicly acknowledged in the aforementioned repo, and actual authorship is maintained by Github in a much more effective and elegant way! Finally, a few references to "Mycroft AI" were changed to the correct legal entity name "Mycroft AI Inc." ==== Fixed Issues ==== #403 Update License.md and file headers to Apache 2.0 #400 Update LICENSE.md ==== Documentation Notes ==== Deprecated the ScheduledSkill and ScheduledCRUDSkill classes. These capabilities have been superceded by the more flexible MycroftSkill class methods schedule_event(), schedule_repeating_event(), update_event(), and cancel_event().
2017-10-04 06:28:44 +00:00
# http://www.apache.org/licenses/LICENSE-2.0
#
Change to Apache 2.0 license from GPLv3.0 This commit officially switches the mycroft-core repository from GPLv3.0 licensing to Apache 2.0. All dependencies on GPL'ed code have been removed and we have contacted all previous contributors with still-existing code in the repository to agree to this change. Going forward, all contributors will sign a Contributor License Agreement (CLA) by visiting https://mycroft.ai/cla, then they will be included in the Mycroft Project's overall Contributor list, found at: https://github.com/MycroftAI/contributors. This cleanly protects the project, the contributor and all who use the technology to build upon. Futher discussion can be found at this blog post: https://mycroft.ai/blog/right-license/ This commit also removes all __author__="" from the code. These lines are painful to maintain and the etiquette surrounding their maintainence is unclear. Do you remove a name from the list if the last line of code the wrote gets replaced? Etc. Now all contributors are publicly acknowledged in the aforementioned repo, and actual authorship is maintained by Github in a much more effective and elegant way! Finally, a few references to "Mycroft AI" were changed to the correct legal entity name "Mycroft AI Inc." ==== Fixed Issues ==== #403 Update License.md and file headers to Apache 2.0 #400 Update LICENSE.md ==== Documentation Notes ==== Deprecated the ScheduledSkill and ScheduledCRUDSkill classes. These capabilities have been superceded by the more flexible MycroftSkill class methods schedule_event(), schedule_repeating_event(), update_event(), and cancel_event().
2017-10-04 06:28:44 +00:00
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
import json
2017-04-25 19:15:19 +00:00
import subprocess
import sys
2017-02-21 05:43:50 +00:00
import time
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
from threading import Timer, Thread, Event, Lock
import gc
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
import os
from os.path import exists, join
import mycroft.dialog
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
import mycroft.lock
2017-04-05 22:11:45 +00:00
from mycroft import MYCROFT_ROOT_PATH
from mycroft.api import is_paired
from mycroft.configuration import Configuration
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
from mycroft.messagebus.client.ws import WebsocketClient
2017-04-06 23:08:23 +00:00
from mycroft.messagebus.message import Message
2017-04-06 01:01:40 +00:00
from mycroft.skills.core import load_skill, create_skill_descriptor, \
MainModule, FallbackSkill
from mycroft.skills.event_scheduler import EventScheduler
from mycroft.skills.intent_service import IntentService
from mycroft.skills.padatious_service import PadatiousService
2017-04-25 22:18:43 +00:00
from mycroft.util import connected
2017-09-18 18:55:58 +00:00
from mycroft.util.log import LOG
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
ws = None
event_scheduler = None
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
skill_manager = None
DEBUG = Configuration.get().get("debug", False)
skills_config = Configuration.get().get("skills")
BLACKLISTED_SKILLS = skills_config.get("blacklisted_skills", [])
PRIORITY_SKILLS = skills_config.get("priority_skills", [])
SKILLS_DIR = '/opt/mycroft/skills'
installer_config = Configuration.get().get("SkillInstallerSkill")
MSM_BIN = installer_config.get("path", join(MYCROFT_ROOT_PATH, 'msm', 'msm'))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
MINUTES = 60 # number of seconds in a minute (syntatic sugar)
2017-04-05 22:11:45 +00:00
2017-03-14 16:12:34 +00:00
2017-02-21 05:43:50 +00:00
def connect():
global ws
2017-02-21 05:43:50 +00:00
ws.run_forever()
def _starting_up():
"""
Start loading skills.
Starts
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
- SkillManager to load/reloading of skills when needed
- a timer to check for internet connection
- adapt intent service
- padatious intent service
"""
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
global ws, skill_manager, event_scheduler
2017-02-21 05:43:50 +00:00
ws.on('intent_failure', FallbackSkill.make_intent_failure_handler(ws))
# Create the Intent manager, which converts utterances to intents
# This is the heart of the voice invoked skill system
2017-11-01 21:47:01 +00:00
service = IntentService(ws)
PadatiousService(ws, service)
event_scheduler = EventScheduler(ws)
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Create a thread that monitors the loaded skills, looking for updates
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
skill_manager = SkillManager(ws)
skill_manager.daemon = True
skill_manager.start()
2016-12-20 21:19:22 +00:00
# Wait until skills have been loaded once before starting to check
# network connection
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
skill_manager.wait_loaded_priority()
check_connection()
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
2017-04-25 22:18:43 +00:00
def check_connection():
2017-08-21 15:05:03 +00:00
"""
Check for network connection. If not paired trigger pairing.
Runs as a Timer every second until connection is detected.
"""
2017-04-25 22:18:43 +00:00
if connected():
ws.emit(Message('mycroft.internet.connected'))
# check for pairing, if not automatically start pairing
if not is_paired():
# begin the process
payload = {
'utterances': ["pair my device"],
'lang': "en-us"
}
ws.emit(Message("recognizer_loop:utterance", payload))
2017-10-10 19:08:06 +00:00
else:
from mycroft.api import DeviceApi
api = DeviceApi()
api.update_version()
2017-04-25 22:18:43 +00:00
else:
thread = Timer(1, check_connection)
thread.daemon = True
thread.start()
def _get_last_modified_date(path):
"""
Get last modified date excluding compiled python files, hidden
directories and the settings.json file.
Arg:
path: skill directory to check
Returns: time of last change
"""
last_date = 0
root_dir, subdirs, files = os.walk(path).next()
# get subdirs and remove hidden ones
subdirs = [s for s in subdirs if not s.startswith('.')]
for subdir in subdirs:
2017-08-22 06:45:06 +00:00
for root, _, _ in os.walk(join(path, subdir)):
base = os.path.basename(root)
# checking if is a hidden path
if not base.startswith(".") and not base.startswith("/."):
last_date = max(last_date, os.path.getmtime(root))
# check files of interest in the skill root directory
files = [f for f in files
if not f.endswith('.pyc') and f != 'settings.json']
for f in files:
last_date = max(last_date, os.path.getmtime(os.path.join(path, f)))
return last_date
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
class SkillManager(Thread):
2017-10-13 09:22:01 +00:00
""" Load, update and manage instances of Skill on this system. """
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def __init__(self, ws):
super(SkillManager, self).__init__()
self._stop_event = Event()
self._loaded_priority = Event()
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.next_download = time.time() - 1 # download ASAP
self.loaded_skills = {}
self.msm_blocked = False
self.ws = ws
# Conversation management
ws.on('skill.converse.request', self.handle_converse_request)
# Update on initial connection
ws.on('mycroft.internet.connected', self.schedule_update_skills)
# Update upon request
ws.on('skillmanager.update', self.schedule_update_skills)
# Register handlers for external MSM signals
ws.on('msm.updating', self.block_msm)
ws.on('msm.removing', self.block_msm)
ws.on('msm.installing', self.block_msm)
ws.on('msm.updated', self.restore_msm)
ws.on('msm.removed', self.restore_msm)
ws.on('msm.installed', self.restore_msm)
# when locked, MSM is active or intentionally blocked
self.__msm_lock = Lock()
self.__ext_lock = Lock()
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def schedule_update_skills(self, message=None):
2017-10-13 09:22:01 +00:00
""" Schedule a skill update to take place directly. """
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Update skills at next opportunity
self.next_download = time.time() - 1
def block_msm(self, message=None):
2017-10-13 09:22:01 +00:00
""" Disallow start of msm. """
# Make sure the external locking of __msm_lock is done in correct order
with self.__ext_lock:
if not self.msm_blocked:
self.__msm_lock.acquire()
self.msm_blocked = True
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def restore_msm(self, message=None):
2017-10-13 09:22:01 +00:00
""" Allow start of msm if not allowed. """
# Make sure the external locking of __msm_lock is done in correct order
with self.__ext_lock:
if self.msm_blocked:
self.__msm_lock.release()
self.msm_blocked = False
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def download_skills(self, speak=False):
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
""" Invoke MSM to install default skills and/or update installed skills
Args:
speak (bool, optional): Speak the result? Defaults to False
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
"""
# Don't invoke msm if already running
if exists(MSM_BIN) and self.__msm_lock.acquire():
try:
# Invoke the MSM script to do the hard work.
LOG.debug("==== Invoking Mycroft Skill Manager: " + MSM_BIN)
p = subprocess.Popen(MSM_BIN + " default",
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
res = p.returncode
# Always set next update to an hour from now if successful
if res == 0:
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.next_download = time.time() + 60 * MINUTES
if res == 0 and speak:
self.ws.emit(Message("speak", {'utterance':
mycroft.dialog.get("skills updated")}))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
return True
elif not connected():
LOG.error('msm failed, network connection not available')
if speak:
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get(
"not connected to the internet")}))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.next_download = time.time() + 5 * MINUTES
return False
elif res != 0:
LOG.error(
'msm failed with error {}: {}'.format(
res, output))
if speak:
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get(
"sorry I couldn't install default skills")}))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.next_download = time.time() + 5 * MINUTES
return False
finally:
self.__msm_lock.release()
else:
LOG.error("Unable to invoke Mycroft Skill Manager: " + MSM_BIN)
def _load_or_reload_skill(self, skill_folder):
2017-10-13 09:22:01 +00:00
"""
Check if unloaded skill or changed skill needs reloading
and perform loading if necessary.
"""
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
if skill_folder not in self.loaded_skills:
self.loaded_skills[skill_folder] = {
"id": hash(os.path.join(SKILLS_DIR, skill_folder))
}
skill = self.loaded_skills.get(skill_folder)
skill["path"] = os.path.join(SKILLS_DIR, skill_folder)
# check if folder is a skill (must have __init__.py)
if not MainModule + ".py" in os.listdir(skill["path"]):
return
# getting the newest modified date of skill
modified = _get_last_modified_date(skill["path"])
last_mod = skill.get("last_modified", 0)
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# checking if skill is loaded and wasn't modified
if skill.get("loaded") and modified <= last_mod:
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
return
# check if skill was modified
elif skill.get("instance") and modified > last_mod:
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# check if skill is allowed to reloaded
if not skill["instance"].reload_skill:
return
LOG.debug("Reloading Skill: " + skill_folder)
# removing listeners and stopping threads
skill["instance"].shutdown()
if DEBUG:
gc.collect() # Collect garbage to remove false references
# Remove two local references that are known
refs = sys.getrefcount(skill["instance"]) - 2
if refs > 0:
LOG.warning(
"After shutdown of {} there are still "
"{} references remaining. The skill "
"won't be cleaned from memory."
.format(skill['instance'].name, refs))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
del skill["instance"]
# (Re)load the skill from disk
with self.__msm_lock: # Make sure msm isn't running
skill["loaded"] = True
desc = create_skill_descriptor(skill["path"])
skill["instance"] = load_skill(desc,
self.ws, skill["id"],
BLACKLISTED_SKILLS)
skill["last_modified"] = modified
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def load_skill_list(self, skills_to_load):
""" Load the specified list of skills from disk
Args:
skills_to_load (list): list of skill directory names to load
"""
if exists(SKILLS_DIR):
# checking skills dir and getting all priority skills there
skill_list = [folder for folder in filter(
lambda x: os.path.isdir(os.path.join(SKILLS_DIR, x)),
os.listdir(SKILLS_DIR)) if folder in skills_to_load]
for skill_folder in skill_list:
self._load_or_reload_skill(skill_folder)
def run(self):
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
""" Load skills and update periodically from disk and internet """
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Load priority skills first, in order (very first time this will
# occur before MSM has run)
self.load_skill_list(PRIORITY_SKILLS)
self._loaded_priority.set()
# Scan the file folder that contains Skills. If a Skill is updated,
# unload the existing version from memory and reload from the disk.
while not self._stop_event.is_set():
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Update skills once an hour
2017-10-13 09:22:01 +00:00
if time.time() >= self.next_download:
self.download_skills()
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Look for recently changed skill(s) needing a reload
if exists(SKILLS_DIR):
# checking skills dir and getting all skills there
list = filter(lambda x: os.path.isdir(
os.path.join(SKILLS_DIR, x)), os.listdir(SKILLS_DIR))
for skill_folder in list:
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self._load_or_reload_skill(skill_folder)
# remember the date of the last modified skill
modified_dates = map(lambda x: x.get("last_modified"),
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.loaded_skills.values())
# Pause briefly before beginning next scan
time.sleep(2)
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Do a clean shutdown of all skills
for skill in self.loaded_skills:
try:
self.loaded_skills[skill]['instance'].shutdown()
except BaseException:
pass
def wait_loaded_priority(self):
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
""" Block until all priority skills have loaded """
while not self._loaded_priority.is_set():
time.sleep(1)
def stop(self):
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
""" Tell the manager to shutdown """
self._stop_event.set()
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
def handle_converse_request(self, message):
""" Check if the targeted skill id can handle conversation
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
If supported, the conversation is invoked.
"""
skill_id = int(message.data["skill_id"])
utterances = message.data["utterances"]
lang = message.data["lang"]
# loop trough skills list and call converse for skill with skill_id
for skill in self.loaded_skills:
if self.loaded_skills[skill]["id"] == skill_id:
try:
instance = self.loaded_skills[skill]["instance"]
except BaseException:
LOG.error("converse requested but skill not loaded")
self.ws.emit(Message("skill.converse.response", {
"skill_id": 0, "result": False}))
return
try:
result = instance.converse(utterances, lang)
self.ws.emit(Message("skill.converse.response", {
"skill_id": skill_id, "result": result}))
return
except BaseException:
LOG.exception(
"Error in converse method for skill " + str(skill_id))
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
self.ws.emit(Message("skill.converse.response",
{"skill_id": 0, "result": False}))
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
def main():
global ws
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Create PID file, prevent multiple instancesof this service
2017-10-13 09:22:01 +00:00
mycroft.lock.Lock('skills')
# Connect this Skill management process to the websocket
ws = WebsocketClient()
Configuration.init(ws)
ignore_logs = Configuration.get().get("ignore_logs")
2017-04-06 17:45:28 +00:00
# Listen for messages and echo them for logging
def _echo(message):
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
try:
_message = json.loads(message)
2017-04-06 17:45:28 +00:00
if _message.get("type") in ignore_logs:
return
if _message.get("type") == "registration":
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
# do not log tokens from registration messages
_message["data"]["token"] = None
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
message = json.dumps(_message)
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
except BaseException:
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
pass
2017-09-18 18:55:58 +00:00
LOG('SKILLS').debug(message)
2017-04-17 17:25:27 +00:00
ws.on('message', _echo)
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Startup will be called after websocket is fully live
ws.once('open', _starting_up)
ws.run_forever()
In the 1970s computer users had to understand the arcane syntax of the machines they used. They programed their computers using the machine's native language and hardly gave it a thought. The 1980s birthed a new form of interaction between computers and users. For the first time computers became capable of understanding the most basic form of human communication - pointing and grunting. The mouse and the GUI revolutionized computing and made computers accessible to the masses. We have now entered a third era. We are rapidly approaching a time when computer systems will understand human language and respond using the most natural form of human communication – speech. This is an important development. Some might even call it revolutionary. Despite its importance, however, the technologies that will underpin this new method of interaction are the property of major tech firms who don't necessarily have the public's best interests at heart. Not anymore. Meet Mycroft – the worlds first open source natural language platform. Mycroft understands human language and responds with speech. It is being designed to run on anything from a phone to an automobile and will change the way we interact with open source technologies in profound ways. Our goal here at Mycroft is to improve this technology to the point that when you interact with the software it is impossible to tell if you are talking to a human or a machine. This initial release of the Mycroft software represents a significant effort by the Mycroft community to give the open source world access to this important technology. We are all hoping that the software will be useful to the public and will help to usher in a new era of human machine interaction. Our community welcomes everyone to use Mycroft, improve the software and contribute back to the project. With your help and support we can truly make Mycroft an AI for everyone. Joshua W Montgomery – May 17, 2016
2016-05-20 14:16:01 +00:00
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
if event_scheduler:
event_scheduler.shutdown()
SkillManager, msm messagebus notifications Significantly reworked the loading/updating of Skills. Unified all management under a single SkillManager class. This class runs as a thread that initially loads, upgrades (via MSM) and reloads skills. Removed the independent threads that were being run. The skill updating still happens once an hour, but works in conjunction with the scan to reload modified skills. Also added messagebus notifications from MSM so mycroft-core can pause reloading skills until the installation is complete. Added a new mycroft.messagebus.send module to allow command line interaction with the messagebus, e.g.: python -m mycroft.messagebus.send mycroft.wifi.start python -m mycroft.messagebus.send speak '{"utterance":"hello"}' ==== Fixed Issues ==== MSM installs that have PIP dependencies were failing, as the load would occur after code was retrieved but before PIP install completed. Restart was required to load new skills. ==== Tech Notes ==== TODO: Change the way we manage modules. The auto-load of the remote configuration for the module is silly, slow and wasteful. I made the WebsocketClient.build_url() method static in anticipation of being able to do this more efficiently when the submodule load doesn't hit the remove API automatically. ==== Localization Notes ==== Modified 'sorry I couldn't install default skills' message. ==== Protocol Notes ==== MSM now generates: msm.updating msm.installing msm.install.succeeded { "skill" : name } msm.install.failed { "skill" : name, "error" : code } msm.installed msm.updated msm.removing msm.remove.succeeded { "skill" : name } msm.remove.failed { "skill" : name, "error" : code } msm.removed An update can now be forced by posting 'skillmanager.update' to the messagebus.
2017-10-13 07:21:58 +00:00
# Terminate all running threads that update skills
if skill_manager:
skill_manager.stop()
skill_manager.join()
2017-02-22 00:00:11 +00:00
finally:
sys.exit()