Commit Graph

888 Commits (3fea4b1e6fa2d3bfd6f620fcd3e188feb4903780)

Author SHA1 Message Date
Åke 75ad11b9d0
Merge pull request #2256 from forslund/refactor-split-mycroftskill
Refactor MycroftSkill
2019-08-30 18:21:13 +02:00
Åke Forslund 02b49edc99 Fix typo when unreferencing skill after failed load 2019-08-30 14:57:27 +02:00
Åke Forslund 077df67479 Disentangle event scheduler interface from skill 2019-08-30 13:32:00 +02:00
Åke Forslund cbf2fc63a9 Remove skill logic from create_wrapper
- Remove once-logic from the default handler wrapper, no need to do it there.
- Add docstring for handle_wrapper
- add the on_start, on_end handlers and move skill logic to respective
handlers.
2019-08-30 13:00:26 +02:00
Åke Forslund 87d9512093 Update get_scheduled_event_status()
Use the more modern bus.wait_for_response()
2019-08-30 13:00:26 +02:00
Åke Forslund c1d07bbe23 Add comments and clean up IntentServiceInterface 2019-08-30 13:00:26 +02:00
Åke Forslund d461ffe63c Update docstrings and variable names of EventSchedulerInterface 2019-08-30 13:00:26 +02:00
Åke Forslund f081404ce3 Further cleanup 2019-08-30 13:00:26 +02:00
Åke Forslund 5e558647e7 Refactor translation methods
Move file reading logic into skill_data.py
2019-08-30 13:00:26 +02:00
Åke Forslund e2ec2ef8d1 Reduce complexity of get_response() 2019-08-30 13:00:26 +02:00
Åke Forslund 2d95ed9e35 Move complexity to IntentServiceInterface
Move much of the complex methods for registering intents to the
IntentServiceInterface to reduce bloat of MycroftSkill
2019-08-30 13:00:26 +02:00
Åke Forslund 5402f8ae22 Use remove_all_listeners when cleaning 2019-08-30 13:00:26 +02:00
Åke Forslund 245a4cb698 Refactor adapt intent data loading routines
- The data loading no longer require the bus
- Add an intent service interface class for better testing
- Update test cases
2019-08-30 13:00:26 +02:00
Åke Forslund 7393d9a670 Create container class for tracking skill handlers
This container remembers registered skills and allows unregistering
all handlers connected to a skill at shutdown.
2019-08-30 13:00:26 +02:00
Åke Forslund a187a17d4d Set MycroftSkill.root_dir in __init__()
This also removes the _dir member which cointains the same information.
2019-08-30 13:00:26 +02:00
Åke Forslund f655152717 Minor cleanup of MycroftSkill
- Create separate method for regisetering mycroft system event handlers
- Fix some string concatenations
- Group acknowledge together with speak and speak_dialog
2019-08-30 13:00:26 +02:00
Åke Forslund b28d63cf71 Make register_intent decorator register all intent types
This makes the register_intent decorator work for all types of intents,
both Adapt and Padatious.
2019-08-30 13:00:26 +02:00
Åke Forslund f5cdeb76ce Move open_intent_envelope to intent_service 2019-08-30 13:00:26 +02:00
Åke Forslund 0759d6f8e1 Split of mycroft skill decorators into new file
Split of decorators from the mycroft_skill file and create a submodule
for mycroft_skill
2019-08-30 13:00:26 +02:00
Åke Forslund a3429dbd96 Create EventSchedulerInterface class
Group event scheduler interface logic into subclass
2019-08-30 13:00:26 +02:00
Åke Forslund 2e82f64519 Populate root_dir in __init__ from file location 2019-08-30 13:00:26 +02:00
Åke Forslund 70307c073a Fix stacktrace on use of deprecated config member 2019-08-24 12:06:49 +02:00
Åke Forslund 4d0e848965 Use from folder instead of dict lookup 2019-08-23 16:52:32 +02:00
Åke Forslund 6736513ae7 Fix SkillUpdater creator
- Since the bus emitter is currently not necessary it's set as an optional
parameter.
- Add proper class docstring
2019-08-23 16:52:31 +02:00
Chris Veilleux 48ca79f388 Improve scanning for decorated handlers
This will recurse down to MycroftSkill class but not include it. for
most skills this will mean only the methods / variables added by the
skill creator
2019-08-23 16:51:53 +02:00
Chris Veilleux be79b193b4 changed to use newer version of msm_wrapper. 2019-08-23 16:07:46 +02:00
Chris Veilleux ebfd367b98 Changed skill manager and updater to reflect changes to MSM.
Cached the MSM creation logic to improve performance.
2019-08-23 16:07:26 +02:00
Åke Forslund 8996972e78 Fix reload_allowed check
Fix logic precedence error and add test for the previous failing
condition.
2019-08-21 16:33:55 +02:00
Åke Forslund bd0456f4e6 Fix issue where skills fail during initialize()
An exception in skill's initialize method would be reraised and cause
the main loading routine to halt. This does not reraise the exception,
instead the instance reference is removed.
2019-08-21 10:11:47 +02:00
Chris Veilleux 3bd3dd1bed 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 12:02:39 +02:00
Kris Gesling 3cacdaaaab
Fix TypeError for number values in settings
In some instances, the backend returns number setting values as an integer rather than a string.

This has been seen in the wild but has been difficult to replicate. The circumstances under which it happens are still unclear. I was able to semi-consistently have a number returned as int from the [Severe Weather Skill](https://github.com/domcross/severe-weather-information-skill) when editing an unrelated setting. To test, remove the 3 character country code (`[A-Z]{3} - `) from the service options of this skill .

This seems to be the quickest fix for it, but worth investigating further from the backend.
2019-08-17 08:36:00 +09:30
David Wagner db2ea07f18
Merge pull request #2236 from forslund/bugfix/system-update
Allow startup if update attempt occurs
2019-08-12 14:31:34 -05:00
Kris Gesling b357874c25
Merge pull request #2235 from MycroftAI/bugfix/padatious-detach-unregistered
Handle removing unregistered intents
2019-08-01 08:35:39 +09:30
Åke Forslund e9cc683dbe Allow startup if update attempt occurs
update_attempt will block waiting for the update to complete and the
update will shutdown the running skills process if an update is needed.
2019-07-26 17:40:59 +02:00
Åke 7ebf58919e
Merge pull request #2233 from forslund/refactor/event-emitter
Small cleanup of the event scheduler
2019-07-26 17:10:23 +02:00
Åke Forslund 13db3d32a3 Handle removing unregistered intents
This small change adds a check that the intent has been registered
before removing it.

If an unregistered intent was removed padatious would silently throw an
exception due to a list operation error. But when run synchronously from
the skill tester this silent exception was actually loud causing skills
to fail to load.
2019-07-26 16:04:16 +02:00
Åke 5eba242487
Merge pull request #2221 from forslund/refactor/split-skills-core
Split mycroft.skills.core
2019-07-26 08:54:26 +02:00
Chris Veilleux 0bde1bc9df Refactor skill service (#2220)
Major refactoring of the skills startup sequence
- Restructure to a less nested structure
- Remove usage of globals by wrapping a lot of state variables into a class this allows for things like caching a negative pairing status throughout the startup process
2019-07-26 08:53:27 +02:00
Åke Forslund 1f6adda6fd Small cleanup of the event scheduler
- Update docstrings
- Fix camelcase member
2019-07-25 08:44:20 +02:00
Åke Forslund 846723cca0 Limit creation attempts of msm-lock
the msm-lock was created in global scope making all mycroft processes
trying to create it. This moves init to actual usage of the lock
2019-07-24 12:16:05 +02:00
Åke Forslund db94123d96 Replace oldstyle super class access with new 2019-07-22 09:24:36 +02:00
Åke Forslund 5dc8802146 Look over docstrings.
Update docstrings of the files affected by this reoriganization.
- PEP 257
- Add missing
2019-07-22 09:16:53 +02:00
Åke Forslund b7b5e9bfcb Refactor mycroft.skills.core
- MycroftSkill and related core functions to mycroft_skill.py
- FallbackSkill to fallback_skill.py
- Add important classes decorators and functions to __init__.py
- move SkillGUI class to the enclosure along with the other enclosure
  interfaces

core.py retains the same members as previously by means of imports to
retain backwards compatibility. When most of the available skills starts
using this new structure properly
2019-07-22 06:46:31 +02:00
Åke bb779e6136
Merge pull request #2217 from forslund/bugfix/quick-download
Move quick skill update to after internet check
2019-07-19 13:13:03 +02:00
Chris Veilleux d8f3095d40 Rename the message bus client and abstract config loading
Message bus config loading is now shared by service and client.

messagebus.client.ws file is still available in case skills are using it. It is a backport that inherits from the new MessageBusClient class. Adds depreciation warning.
2019-07-19 08:16:54 +02:00
Åke 345e28f5fa
Merge pull request #2206 from MycroftAI/doc/readthedocs2
Quickfix: readthedocs build
2019-07-18 14:55:13 +02:00
Åke Forslund 8b03a93dc1 Move quick skill update to after internet check 2019-07-18 14:25:31 +02:00
Åke Forslund 3e0cac8c1e Trigger settings update on pairing complete 2019-07-14 21:01:44 +02:00
Åke Forslund ddb9d5b0a2 Hack: Fix readthedocs build
The Mycroft API documentation were blank due to the import of the yaml
module for some reason. This moves the import into the method where it's
used
2019-07-14 08:17:05 +02:00
David Wagner 4b480dcf32
Add mycroft_mark_2pi to platforms needing ntp sync 2019-07-12 06:56:35 -05:00