mycroft-core/mycroft/skills/__main__.py

277 lines
9.6 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.
#
"""Daemon launched at startup to handle skill activities.
In this repo, you will not find an entry called mycroft-skills in the bin
directory. The executable gets added to the bin directory when installed
(see setup.py)
"""
2017-02-21 05:43:50 +00:00
import time
from threading import 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
import mycroft.lock
Refactor skill manager (#2237) Split skill_manager into three separate classes, SkillManager, SkillUpdater and SkillLoader splitting the responsibility into logical units * Split the SkillManager.__init__ code to determine the download times into a new method * Make docstrings consistent and PEP257 compliant. Also fixed a couple of spelling errors * fixed two issues introduced in the previous refactoring * removed unnecessary assignment of an instance attribute to a local variable * updated the unit test to mock out code that reaches outside of core, like MSM and the configuration manager. * add several unittests and refactored load_priority method. * add a test for the _get_last_modified_date function. * add "quick" argument to docstring * removed unused import * new class containing the logic to periodically update/install skills and send skill manifests to the backend. * import MsmException from where it is defined, not from the skill manager. * add some logging to the skill updater * remove code now in SkillUpdater from SkillManager * added imports to __init__.py to define the API into the message bus package * new base class for unit tests and module for reusable mocks * new skill loader class that will replace the _load_or_reload_skill() method in the SkillManager class. * moved skill loading logic from core.py into skill_loader.py, resulting in some refactoring of skill loader and skill manager. change unit tests to match. * added back some spacing that was inadvertently removed. * change skill tester to use new SkillLoader class. * Separate reload required check from performing reload to make logic easier to follow * Track skills that failed to load to handle infinite loop at first load if skill fails to load * Allow reloading skills that has failed to load * Simplify first load of skills - create activate, deactivate and unload methods for skill_loader objects - add sanity checks before activating and deactivating skills - Update activation/deactivation test cases
2019-08-20 10:02:39 +00:00
from msm.exceptions import MsmException
from mycroft import dialog
from mycroft.api import is_paired, BackendDown, DeviceApi
from mycroft.audio import wait_while_speaking
from mycroft.enclosure.api import EnclosureAPI
from mycroft.configuration import Configuration
from mycroft.messagebus.client import MessageBusClient
2017-04-06 23:08:23 +00:00
from mycroft.messagebus.message import Message
from mycroft.util import (
connected,
create_echo_function,
create_daemon,
reset_sigint_handler,
wait_for_exit_signal
)
2019-03-14 08:48:03 +00:00
from mycroft.util.lang import set_active_lang
from mycroft.util.log import LOG
from .core import FallbackSkill
from .event_scheduler import EventScheduler
from .intent_service import IntentService
from .padatious_service import PadatiousService
Refactor skill manager (#2237) Split skill_manager into three separate classes, SkillManager, SkillUpdater and SkillLoader splitting the responsibility into logical units * Split the SkillManager.__init__ code to determine the download times into a new method * Make docstrings consistent and PEP257 compliant. Also fixed a couple of spelling errors * fixed two issues introduced in the previous refactoring * removed unnecessary assignment of an instance attribute to a local variable * updated the unit test to mock out code that reaches outside of core, like MSM and the configuration manager. * add several unittests and refactored load_priority method. * add a test for the _get_last_modified_date function. * add "quick" argument to docstring * removed unused import * new class containing the logic to periodically update/install skills and send skill manifests to the backend. * import MsmException from where it is defined, not from the skill manager. * add some logging to the skill updater * remove code now in SkillUpdater from SkillManager * added imports to __init__.py to define the API into the message bus package * new base class for unit tests and module for reusable mocks * new skill loader class that will replace the _load_or_reload_skill() method in the SkillManager class. * moved skill loading logic from core.py into skill_loader.py, resulting in some refactoring of skill loader and skill manager. change unit tests to match. * added back some spacing that was inadvertently removed. * change skill tester to use new SkillLoader class. * Separate reload required check from performing reload to make logic easier to follow * Track skills that failed to load to handle infinite loop at first load if skill fails to load * Allow reloading skills that has failed to load * Simplify first load of skills - create activate, deactivate and unload methods for skill_loader objects - add sanity checks before activating and deactivating skills - Update activation/deactivation test cases
2019-08-20 10:02:39 +00:00
from .skill_manager import SkillManager
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
RASPBERRY_PI_PLATFORMS = ('mycroft_mark_1', 'picroft', 'mycroft_mark_2pi')
2017-03-14 16:12:34 +00:00
2017-02-21 05:43:50 +00:00
class DevicePrimer(object):
"""Container handling the device preparation.
2017-02-21 05:43:50 +00:00
Arguments:
message_bus_client: Bus client used to interact with the system
Refactor skill manager (#2237) Split skill_manager into three separate classes, SkillManager, SkillUpdater and SkillLoader splitting the responsibility into logical units * Split the SkillManager.__init__ code to determine the download times into a new method * Make docstrings consistent and PEP257 compliant. Also fixed a couple of spelling errors * fixed two issues introduced in the previous refactoring * removed unnecessary assignment of an instance attribute to a local variable * updated the unit test to mock out code that reaches outside of core, like MSM and the configuration manager. * add several unittests and refactored load_priority method. * add a test for the _get_last_modified_date function. * add "quick" argument to docstring * removed unused import * new class containing the logic to periodically update/install skills and send skill manifests to the backend. * import MsmException from where it is defined, not from the skill manager. * add some logging to the skill updater * remove code now in SkillUpdater from SkillManager * added imports to __init__.py to define the API into the message bus package * new base class for unit tests and module for reusable mocks * new skill loader class that will replace the _load_or_reload_skill() method in the SkillManager class. * moved skill loading logic from core.py into skill_loader.py, resulting in some refactoring of skill loader and skill manager. change unit tests to match. * added back some spacing that was inadvertently removed. * change skill tester to use new SkillLoader class. * Separate reload required check from performing reload to make logic easier to follow * Track skills that failed to load to handle infinite loop at first load if skill fails to load * Allow reloading skills that has failed to load * Simplify first load of skills - create activate, deactivate and unload methods for skill_loader objects - add sanity checks before activating and deactivating skills - Update activation/deactivation test cases
2019-08-20 10:02:39 +00:00
config (dict): Mycroft configuration
"""
def __init__(self, message_bus_client, config):
self.bus = message_bus_client
self.platform = config['enclosure'].get("platform", "unknown")
self.enclosure = EnclosureAPI(self.bus)
self.is_paired = False
self.backend_down = False
# Remember "now" at startup. Used to detect clock changes.
def prepare_device(self):
"""Internet dependent updates of various aspects of the device."""
self._get_pairing_status()
self._update_system_clock()
2019-09-24 20:35:11 +00:00
self._update_system()
# Above will block during update process and kill this instance if
# new software is installed
2019-09-24 20:35:11 +00:00
if self.backend_down:
self._notify_backend_down()
else:
self._display_skill_loading_notification()
self.bus.emit(Message('mycroft.internet.connected'))
self._ensure_device_is_paired()
self._update_device_attributes_on_backend()
def _get_pairing_status(self):
"""Set an instance attribute indicating the device's pairing status"""
try:
self.is_paired = is_paired(ignore_errors=False)
except BackendDown:
LOG.error('Cannot complete device updates due to backend issues.')
self.backend_down = True
if self.is_paired:
LOG.info('Device is paired')
def _update_system_clock(self):
"""Force a sync of the local clock with the Network Time Protocol.
The NTP sync is only forced on Raspberry Pi based devices. The
assumption being that these devices are only running Mycroft services.
We don't want to sync the time on a Linux desktop device, for example,
because it could have a negative impact on other software running on
that device.
"""
if self.platform in RASPBERRY_PI_PLATFORMS:
LOG.info('Updating the system clock via NTP...')
if self.is_paired:
# Only display time sync message when paired because the prompt
# to go to home.mycroft.ai will be displayed by the pairing
# skill when pairing
self.enclosure.mouth_text(dialog.get("message_synching.clock"))
self.bus.wait_for_response(
Message('system.ntp.sync'),
'system.ntp.sync.complete',
15
)
def _notify_backend_down(self):
"""Notify user of inability to communicate with the backend."""
self._speak_dialog(dialog_id="backend.down")
self.bus.emit(Message("backend.down"))
def _display_skill_loading_notification(self):
"""Indicate to the user that skills are being loaded."""
self.enclosure.eyes_color(189, 183, 107) # dark khaki
self.enclosure.mouth_text(dialog.get("message_loading.skills"))
def _ensure_device_is_paired(self):
"""Determine if device is paired, if not automatically start pairing.
Pairing cannot be performed if there is no connection to the back end.
So skip pairing if the backend is down.
"""
if not self.is_paired and not self.backend_down:
LOG.info('Device not paired, invoking the pairing skill')
payload = dict(utterances=["pair my device"], lang="en-us")
self.bus.emit(Message("recognizer_loop:utterance", payload))
def _update_device_attributes_on_backend(self):
"""Communicate version information to the backend.
The backend tracks core version, enclosure version, platform build
and platform name for each device, if it is known.
"""
if self.is_paired:
LOG.info('Sending updated device attributes to the backend...')
try:
api = DeviceApi()
api.update_version()
except Exception:
self._notify_backend_down()
def _update_system(self):
"""Emit an update event that will be handled by the admin service."""
if not self.is_paired:
LOG.info('Attempting system update...')
self.bus.emit(Message('system.update'))
msg = Message(
'system.update',
dict(paired=self.is_paired, platform=self.platform)
)
resp = self.bus.wait_for_response(msg, 'system.update.processing')
if resp and (resp.data or {}).get('processing', True):
self.bus.wait_for_response(
Message('system.update.waiting'),
'system.update.complete',
1000
)
def _speak_dialog(self, dialog_id, wait=False):
data = {'utterance': dialog.get(dialog_id)}
self.bus.emit(Message("speak", data))
if wait:
wait_while_speaking()
def main():
reset_sigint_handler()
# Create PID file, prevent multiple instances of this service
mycroft.lock.Lock('skills')
config = Configuration.get()
# Set the active lang to match the configured one
set_active_lang(config.get('lang', 'en-us'))
# Connect this process to the Mycroft message bus
bus = _start_message_bus_client()
_register_intent_services(bus)
event_scheduler = EventScheduler(bus)
skill_manager = _initialize_skill_manager(bus)
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
_wait_for_internet_connection()
if skill_manager is None:
skill_manager = _initialize_skill_manager(bus)
device_primer = DevicePrimer(bus, config)
device_primer.prepare_device()
skill_manager.start()
wait_for_exit_signal()
shutdown(skill_manager, event_scheduler)
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 _start_message_bus_client():
"""Start the bus client daemon and wait for connection."""
bus = MessageBusClient()
Configuration.set_config_update_handlers(bus)
bus_connected = Event()
bus.on('message', create_echo_function('SKILLS'))
# Set the bus connected event when connection is established
bus.once('open', bus_connected.set)
create_daemon(bus.run_forever)
# Wait for connection
bus_connected.wait()
LOG.info('Connected to messagebus')
return bus
def _register_intent_services(bus):
"""Start up the all intent services and connect them as needed.
Arguments:
bus: messagebus client to register the services on
"""
service = IntentService(bus)
try:
PadatiousService(bus, service)
except Exception as e:
LOG.exception('Failed to create padatious handlers '
'({})'.format(repr(e)))
# Register handler to trigger fallback system
bus.on('intent_failure', FallbackSkill.make_intent_failure_handler(bus))
def _initialize_skill_manager(bus):
Refactor skill manager (#2237) Split skill_manager into three separate classes, SkillManager, SkillUpdater and SkillLoader splitting the responsibility into logical units * Split the SkillManager.__init__ code to determine the download times into a new method * Make docstrings consistent and PEP257 compliant. Also fixed a couple of spelling errors * fixed two issues introduced in the previous refactoring * removed unnecessary assignment of an instance attribute to a local variable * updated the unit test to mock out code that reaches outside of core, like MSM and the configuration manager. * add several unittests and refactored load_priority method. * add a test for the _get_last_modified_date function. * add "quick" argument to docstring * removed unused import * new class containing the logic to periodically update/install skills and send skill manifests to the backend. * import MsmException from where it is defined, not from the skill manager. * add some logging to the skill updater * remove code now in SkillUpdater from SkillManager * added imports to __init__.py to define the API into the message bus package * new base class for unit tests and module for reusable mocks * new skill loader class that will replace the _load_or_reload_skill() method in the SkillManager class. * moved skill loading logic from core.py into skill_loader.py, resulting in some refactoring of skill loader and skill manager. change unit tests to match. * added back some spacing that was inadvertently removed. * change skill tester to use new SkillLoader class. * Separate reload required check from performing reload to make logic easier to follow * Track skills that failed to load to handle infinite loop at first load if skill fails to load * Allow reloading skills that has failed to load * Simplify first load of skills - create activate, deactivate and unload methods for skill_loader objects - add sanity checks before activating and deactivating skills - Update activation/deactivation test cases
2019-08-20 10:02:39 +00:00
"""Create a thread that monitors the loaded skills, looking for updates
2017-04-25 22:18:43 +00:00
Returns:
SkillManager instance or None if it couldn't be initialized
"""
try:
skill_manager = SkillManager(bus)
skill_manager.load_priority()
except MsmException:
# skill manager couldn't be created, wait for network connection and
# retry
skill_manager = None
LOG.info(
'MSM is uninitialized and requires network connection to fetch '
'skill information\nWill retry after internet connection is '
'established.'
)
2017-04-25 22:18:43 +00:00
return skill_manager
2017-04-06 17:45:28 +00:00
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 _wait_for_internet_connection():
while not connected():
time.sleep(1)
2017-04-06 17:45:28 +00:00
2017-04-17 17:25:27 +00:00
def shutdown(skill_manager, event_scheduler):
LOG.info('Shutting down skill service')
if event_scheduler is not None:
event_scheduler.shutdown()
# Terminate all running threads that update skills
if skill_manager is not None:
skill_manager.stop()
skill_manager.join()
LOG.info('Skill service shutdown complete!')
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__":
main()