Commit Graph

973 Commits (e57671ebeb9f8821bd5740ed4f6690a3052ad35e)

Author SHA1 Message Date
Å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
Åke 5555fa398d
Merge pull request #2197 from forslund/feature/skills-startup-speedup
Skills process startup speedup
2019-07-10 16:30:48 +02:00
Åke 80b50598fb
Merge pull request #2196 from forslund/feature/skill-timing-report-skill_id
Add skill_id to skill handler timing report
2019-07-09 22:42:58 +02:00
Åke Forslund 94ab53f47e Handle sending skill manifest
Skill manifest is now sent on each startup if paired otherwise after successful pairing.
2019-07-09 16:52:27 +02:00
Åke Forslund d87ff3a535 Launch settings fetching in thread. 2019-07-09 16:52:27 +02:00
Åke Forslund cd16404455 Download skills if they're stale or in unknown state
Checks if the skills haven't been updated for more than 2 weeks or if
the last_download is undefined. last_download may be undefined if
the .msm file is missing or if the list of installed requirements is
missing so skill requirements may be missing.

This also makes sure the skills are normally loaded before the an update
attemt is tried.
2019-07-09 16:52:27 +02:00
Åke Forslund 58cab5cddb Add support for slowloading skills
Upgrade msm to 0.7.8

Using the new max_threads parameters to MycroftSkillsManager.apply() the
skill loading is reduced to 2 threads if it's during runtime while a
fast update (20 threads) are used if not all default skills are
installed to speed up getting core into a 100% operational state.
2019-07-09 16:52:10 +02:00
Åke Forslund fe31564114 Remove unused imports 2019-07-08 14:41:09 +02:00
Åke Forslund 6466be63d8 Add skill_id to skill handler timing report 2019-07-08 09:12:20 +02:00
Åke Forslund fbcf731556 Remove broken auto-naming of resting_screen_handler
The automatic naming of the resting_screen_handler wasn't working (error
occured if no name was supplied)

Added test case for the function
2019-07-03 08:40:34 +02:00
Åke 12f13ef47c
Merge pull request #2177 from forslund/bugfix/settings-allow-retry-after-delay
Remove incorrect settings meta upload disable flag
2019-07-01 09:35:46 +02:00
Åke Forslund 83b4a91b8b Remove incorrect settings meta upload disable flag
This allows core to retry sending settings meta after a failed attempt
2019-06-29 21:00:15 +02:00
Åke Forslund 2f1f6a6005 Improve MycroftSkill docstring 2019-06-28 15:30:13 +02:00
Åke Forslund 2a65623c6d Read vocab the .voc files as lowercase
A common error is to add capitalization in the .voc files when
translating them using the translate tool.
2019-06-25 11:05:44 +02:00
Chris Rogers a40218da18 Add lock/unlock actions 2019-06-20 12:02:34 +02:00
Chris Rogers 395c31cf29 Fix pep8 issues 2019-06-20 12:02:34 +02:00
Chris Rogers e1a2de7046 Add locate 2019-06-20 12:02:34 +02:00
Chris Rogers c966dbe5bd Add basic state support 2019-06-20 12:02:33 +02:00
Chris Rogers 44d51d15f3 Add speak support 2019-06-20 12:02:33 +02:00
Chris Rogers 3602ff8e87 Begin support for state queries 2019-06-20 12:02:28 +02:00
Steve Penrod 8ca4bb8343
Remove abstractmethod for MycroftSkill.stop()
The MycroftSkill.stop() method does not need to be implemented by the majority of skills, no reason to 'require' its implementation with an abstractmethod.
2019-06-10 13:15:59 -05:00
Chris Rogers d71f67f7ea Allow scheduling events a fractional number of seconds in the future 2019-06-09 22:13:44 -04:00
Åke 626c69bc1d Skill settings cleanup (#2140)
* Handle DelayRequests when uploading blank settingsmeta

* Move Api methods to DeviceApi

This includes delete, put and get skill settings/meta

* Cache skill settings for 30 seconds

The skill settings are cached to reduce number of requests to the backend and increase skill loading speed.

* Remove _request_other_settings method

The endpoint is not used anymore

* Fix issue when the settingsmeta fails to load

Remove an old reference to "BLANK_META" left behind in the exception handler for failing to load settingsmeta.
2019-06-05 18:45:15 -05:00
Aditya Mehra b08f090131 Add System QML support for HTML displays (#2138)
Add SYSTEM_HtmlFrame support for html-url and html-raw and override option for all system qml displays
2019-05-31 12:59:46 +02:00
Åke 6357513970 GUI updates (#2114)
* Catch the new system.gui.user.interaction

This will in turn trigger the gui.page_interaction similar to the page flip but page_number will be None

* Fix issue when adding pages

Seems like appending would fail at times

* Add lock around namespace modifications

* Improve argument description for override_idle
2019-05-31 03:44:09 -05:00
ChristopherRogers1991 b5279e480b
Merge pull request #2133 from forslund/feature/yaml-loader
Use SafeLoader to load settingsmeta yaml
2019-05-27 06:57:46 -04:00
Åke Forslund 21efb0fd69 Use yaml.safe_load() to load settingsmeta yaml
safe_load limits the amount of custom methods that can be supplied with
the yaml and supports the basic yaml features.
2019-05-27 12:25:42 +02:00
Åke b1348de6f7 Feature/msm 0.7.6 (#2136)
* Log error when creating Padatious

* Update msm to v0.7.6

This handles connection errors during the startup procedure and improves
the skill_gid when no network is available
2019-05-23 10:16:37 -07:00
Åke 86df2cefd4 Don't create skill settings for Padatious Service (#2132)
Padatious is registered as a FallbackSkill and was pushing settings to
the backend.

This change allows Padatious to flag to the MycroftSkill class
that no settings should be created. This is done via the new optional
MycroftSkill parameter use_settings.
2019-05-23 10:14:08 -07:00
Åke Forslund c3ac9d8ca7 Remove the delete metadata calls when updating settings
The calls are not implemented and functionality will likely change.
2019-05-21 17:21:45 +02:00
Åke Forslund 2208ee178c Switch to getting skill_gid from msm skill entry 2019-05-21 09:23:02 +02:00
Åke Forslund 4518a11528 Add safety around skillMetadata
skillMetadata could be accessed in settings without it when checking if remote update was needed.
2019-05-18 08:29:26 +02:00
Åke Forslund 6eb2aefbaa Delete remote settings before pushing
- restore storing / loading uuid
- use uuid to delete before pushing settingsmeta
2019-05-18 08:29:26 +02:00
Åke Forslund 4a75526de7 Check both endpoints for settings 2019-05-18 08:29:26 +02:00
Åke Forslund 93a0b31b4e Switch endpoint for fetching settings
use the userSkill endpoint instead of skill endpoint to always be able
to get settings no matter who the owner is.
2019-05-18 08:29:26 +02:00
Åke Forslund f6347ae47c Replace hashed meta with skill_gid as identifier
This also removes the notion of an owner skill and all skills may update settings on the server.
2019-05-18 08:29:26 +02:00
Åke Forslund 693bf2c699 Remove BLANK boilerplate content 2019-05-18 08:29:26 +02:00
Åke Forslund 56ed5a657f Re-add support for skill_gid in settingsmeta upload 2019-05-18 08:29:26 +02:00
Aditya Mehra eb32570efa Feature/System_QML (#2121)
Add support for SYSTEM QML functions for show_text() and show_image()

The ui elements used are stored in the mycroft/res/ui folder
2019-05-16 09:09:01 +02:00
Aditya Mehra ccb23f14bf feature/enable sending qml ui over network (#2106)
Enable sending qml ui over network
2019-05-13 10:43:29 +02:00
ChristopherRogers1991 6dd16915a9 Allow settingsmeta to be a yaml file (#2113)
Allow settingsmeta to be a yaml file in addition to the current .json file
2019-05-13 09:34:39 +02:00
Matthew D. Scholefield 09e7a18b77
Merge pull request #2116 from forslund/feature/delay-on-422
Add delay on failure to upload skillsettingsmeta
2019-05-07 19:28:12 -05:00
Åke Forslund 0b11cdac0a Add delay on failure to upload skillsettingsmeta
Mycroft-core won't retry for 5 minutes on a 422, 500 or 501 error.

This adds a DelayRequests Exception which will cause the settings
fetching Timer thread to sleep for 5 minutes
2019-05-07 14:50:17 +02:00
Chris Rogers aaa1a7f55a Add docs and fix IoTRequest repr 2019-05-06 15:57:49 -04:00
Chris Rogers b3d6cc35c0 Add support for values 2019-05-06 15:57:49 -04:00
Kris Gesling 947fadbe1f fix table formatting for docs display 2019-04-20 13:15:39 +09:30
Kris Gesling 88a822727c
Merge pull request #2095 from forslund/docs/tidying
Tidy up the readthedocs documentation
2019-04-20 03:02:56 +09:30
Matthew D. Scholefield 8c09f88e53
Merge pull request #2088 from forslund/feature/audioservice-list
Feature/audioservice list
2019-04-19 00:30:38 -05:00
Åke 7a8ea0b5cc
Merge pull request #2099 from MycroftAI/commonIoT/trigger
Add trigger action
2019-04-16 11:15:34 +02:00
Åke 3841d5c13c
Merge pull request #2096 from MycroftAI/commonIoT/acknowledge
CommonIOT/acknowledge
2019-04-16 11:14:27 +02:00
Chris Rogers 8a75b77204 Add trigger action 2019-04-15 14:01:35 -04:00
Chris Rogers b975f2f9cf file -> audio_file 2019-04-14 18:36:07 -04:00
Chris Rogers 6afadbed4c Remove wait 2019-04-14 18:32:01 -04:00
Chris Rogers 2a6f113151 Add function to acknowledge success non-verbally 2019-04-14 10:11:52 -04:00
Chris Rogers 61e4aeb55f Make temp, heat, ac things instead of attributes 2019-04-14 10:06:00 -04:00
Åke Forslund 6fbb49c1e9 Add some docstrings for CommonPlay/Query skills 2019-04-14 09:51:26 +02:00
Åke 0a887bf6bb Restore settings polling to 1 minute interval (#2091) 2019-04-10 13:38:58 -05:00
Chris Rogers 7641cc00b0 Add thermostat related attributes 2019-04-08 18:19:52 -04:00
Åke Forslund 9248be1691 Add list of available backends to audioservice
The message returned is a dict of all available audio backends as keys
containing 'supported_uris' listing supported uri types (file:// http://
etc.), 'remote' (bool) True if remote), 'default' (bool) true if the
default audio backend.
2019-04-08 15:28:56 +02:00
Åke Forslund bee167c875 Poll settings only every 5 minutes 2019-04-07 00:26:16 +02:00
Åke Forslund 54781a9249 Reverts back to 19.2.2
Revert "Fix a couple of minor issues intruduced by skill_gid (#2079)"

This reverts commit e046377ce1.

Revert "Merge pull request #2075 from forslund/bugfix/msm_wrapper-license"

This reverts commit 18cfbce0ca, reversing
changes made to 82fa314ce9.

Revert "Feature/skillsmeta gid (#2074)"

This reverts commit 82fa314ce9.
2019-04-07 00:01:36 +02:00
Åke e046377ce1 Fix a couple of minor issues intruduced by skill_gid (#2079)
- name collision for display_name function and variable
- name -> self.name
2019-04-05 16:43:47 -05:00
Åke 637166e624 Revert "Remove reliance on hashed meta (#2076)"
This reverts commit 38123a1fc3.
2019-04-05 17:57:06 +02:00
Åke 38123a1fc3 Remove reliance on hashed meta (#2076)
* Fix skill_gid for modified skills

Used the old '_' after device uuid

* Identify skill using gid

When receiving data from server the "identifier" entry is now removed and in it's stead the skill_gid should be used.

This also removes the "fetch other settings" functionallity since that is no longer relevant.
2019-04-04 02:03:08 -05:00
Åke Forslund f60d2372bb Add missing license header 2019-04-02 18:26:44 +02:00
Åke 82fa314ce9 Feature/skillsmeta gid (#2074)
* Add global id basics to settings meta

- All skills will upload a blank settingsmeta
- a skill_gid will be appended to all settingsmeta upload-data
- Added basic function for generating skill_gid

* Use new skill_gid field.

Populate skill_gid directly from metadata

* Separate travis tmp-dirs

- Update travis script to use tempdir for each python version
- Update test script to handle nonstandard tempdirs
- Generate msm folder using tempdir when running create_msm test

* Add title field with pretty name

* Collect and expand "title" as needed

For title use market-place title or name in settings meta or skillname

* Switch skill_manager create_msm test to 19.02

* Remove leading / trailing Skill in display name

Also rename title displayname to match new mycroft-skills-data

* Lock msm_create and mock the name info test_settings
2019-04-02 11:14:49 -05:00
Åke Forslund 466f187eb7 Remove extra LOG statement 2019-03-28 23:29:07 +01:00
Åke d2e6d310ad Run normalized also when raw matches None (#2073)
If no match was found for the non-normalized utterance it would jump to
the exception handler for StopIteration skipping the normalized step
altogether

This changes the next/StopIteration system for list comprehensions
2019-03-28 15:43:28 -05:00
Åke Forslund 381999d5a8 Minor issues
- padatious sentence defaults
- A bit more explanation about the adapt message utterance
2019-03-28 14:50:50 +01:00
Steve Penrod 342c730a97 Normalize utterances before intent handling
Previously Padatious intent matches were performed on non-normalized text, meaning that things like "what's the weather" wouldn't match a Padatious intent but
"what is the weather" would.

The "utterance" in Adapt intent data will still be non-normalized even if the intent match occurred on a normalized utterance. Retaining the existing behavior.

The "intent_failure" data.  In there, "utterance" is always the raw version, "norm_utt" is the normalized one.

Also added better debugging info for intent matching to the log.

Also addresses a rare issue with the old code where the Adapt context could
have been updated even if the Adapt intent wasn't actually invoked due to
a higher Padatious intent match.
2019-03-28 14:48:26 +01:00
Åke feb82a2bb1 Add the SkillGUI method send_event() (#2057)
* Add the SkillGUI method send_event()

Sends raw mycroft.events.triggered messages to the gui for the skills namespace.

Example usage:
  self.gui.send_event('event_name' {'param1': 12, 'param2': 'abc'})
2019-03-27 01:22:05 -05:00
Chris Rogers d04ad5f8b0 Remove enum.auto
Replace enum.auto with a similar, custom function. This is for python3.4
compatibility.
2019-03-24 14:07:49 -04:00
Åke dfa714c56d
Merge pull request #2059 from MycroftAI/feature/padatious-priority
Adjust and document Padatious loose fallback priority
2019-03-21 23:38:25 +01:00
Steve Penrod 41773a039a Adjust and document Padatious loose fallback priority
The loose (conf > 0.5) Padatious match was previously occurring as Fallback
priority 99. The AIML fallback at priority 90 would consume lots of
utterances, interferring with many skills.  Now Padatious runs at priority
89.

Additionally, added documentation of the intent and fallback system, including
guidelines for priorities.
2019-03-21 17:16:07 -05:00
Åke Forslund c3f2b73794 set_active_lang on startup of skills 2019-03-14 11:00:51 +01:00
Steve Penrod 44f60ec6f3 Change default lang to None, not English
Much of the code used "en-us" as the default value when not specified.
This limited the internationalization potential.  Changing the default
to None and adds the ability to define the default lang code from other
locations in code.  E.g.

```python

from mycroft.util.lang import set_default_lang

set_default_lang("en-us")
print("English date: "+nice_date(dt))

set_default_lang("de-de")
print("German date: "+nice_date(dt))
```

This allows easier localization of Skills by having the framework set the default without any changes necessary by the Skill writers.

Other minor changes:
* Changed the default return value of get_gender*() to None instead of False
2019-03-14 10:57:31 +01:00
ChristopherRogers1991 ffd58cb4ef Feature/common io t updates (#2050)
* Split ADJUST into ADJUST and SET

* Use enum names instead of values.

* Add properties to CommonIoTSkill

* property -> attribute to avoid conflict with builtin

* Add increase and decrease actions

* Fix copy/paste error
2019-03-13 22:51:54 -05:00
Steve Penrod 230c3057b4 Give Padatious high and low match passes
Padatious was accepting fairly low confidence matches (0.5).  This
would match a phrase such as "Where is the Empire State Building?" to the
intent "Where were you born?"  (Which is a 0.54 match)

Now there are two passes mad on the Padatious fallback.  The first is
looking for high confidence matches (> 0.8).  Then other fallbacks -- such
as the CommonQuery fallbacks -- have an opportunity to consume the
utterance.  If they don't consume it, Padatious is invoked again with
looser confidence before finally invoking the Unknown fallback.
2019-03-05 03:33:02 -06:00
Steve Penrod 286fa6314f Imporove user feedback during startup
Now the eyes go to a khaki color and "< < < LOADING < < <" displays
during the skill startup.  When Padatious finishes the first training
we now emit a "mycroft.ready" on the messagebus.

A change to the skill_mark_1 to look for "mycroft.ready" instead of
"mycroft.skills.initialized" provides a good visual change to show that
it is ready for use.
2019-02-28 14:58:19 -06:00
Åke 5529acde12
Merge pull request #2030 from MycroftAI/bugfix/hide-warnings
Hide deprecated warning in certain cases
2019-02-28 21:12:17 +01:00
Steve Penrod f5025f5eaf Fix PEP8 2019-02-28 13:15:03 -06:00
Steve Penrod 419a8c531d Hide deprecated warning in certain cases
The deprecation warning was firing off at the load of every skill when
the decorators are being iterated through by internal code (which
includes the self.config with an @property).  Add check for these
special cases to not show a warning.
2019-02-28 13:11:07 -06:00
Steve Penrod 603973ecf3 Typo in Common Query 'encolsure'
Fixed a type in the Common Query scoring system that broke a bonus check.
2019-02-28 12:39:38 -06:00
Steve Penrod d25d91e034 Tweak CommonPlay scoring
The scoring for CommonPlay would favor skills that responded with overly long
matches.  E.g. "Huey Lewis and the News" would be considered a better fit than
just "News" for the request "Play the News"
2019-02-28 11:06:52 +01:00
Steve Penrod d65555c327 Deprecate self.config in skills (#2025)
* Deprecate self.config in skills

Skills should contain their own settings, the self.config concept is being
deprecated.

Also removed the defaults set for several old MycroftAI skills.  The 19.02
version of these Skills initializes the default values using:
```python
self.settings["key"] = default
```

* Update padatious config to work with the config property.
2019-02-28 10:50:08 +01:00
ChristopherRogers1991 cf5d7b80c5 Feature/common io t (#2015)
* Add base common_iot_skill

* can_run takes IoTRequest

* Minor cleanup + documentation

* Fix pep8 issues

* Adjust scene and entity registration.

The controller skill is not guaranteed to be alive before
CommonIoTSkills, so we must call for values when it is alive, in
addition to accepting them at any time from other skills.

* Safer parsing

* Address PR feedback

* Add skill_id to register message

* Minor docstring edits
2019-02-28 01:31:03 -06:00
Åke d3e6a10ecc GUI Remove pages/namespaces (#2002)
* Add remove page methods

* Implement SkillGUI.clear()

The method will now remove the namespace entirely from the gui.

This adds the message gui.clear.namespace

* Remove debug prints from SkillGUI

* Correcting docstring

* More docstring changes

* Remove whitespace added by Github webUI
2019-02-28 00:21:08 -06:00
Åke 8e495870c2 Feature/skill manager error checks (#1981)
* Attempt to create skill directory if not existing

* Handle missing priority skills

* Minor update of comments

* Handle skill load exception

Make sure an exception while trying to load/reload skill doesn't shutdown thread.

* Handle MsmException during SkillManager creation

If SkillManager can't be created due to an MsmException wait for network connection and retry.

* Update immediately if skill install file is missing

Missing skill install file indicates that this is a new venv and the requirements of the skills will need to be reinstalled.

* Add basic test for skill_manager

Basically only creating the skill_manager but it ensures that msm can be used on all supported python versions
2019-02-28 00:18:48 -06:00
Åke 6c14d7bc36 Refactor/19.02 removes (#2019)
* Remove the deprecated emitter

* Remove channels config key for listener

This has never been used.
2019-02-28 00:09:47 -06:00
Åke 11dae04451 Feature/threaded emitter (#2008)
* Update to pyee 5.0.0

- Update requirement
- Make the SkillSettings class hashable

* Update adapt to 0.3.2

* Upgrade websocket-client

* Remove special threading for common query
2019-02-27 23:41:52 -06:00
Åke 71088f8fcb Feature/update requirements (#1998)
* Update to pyee 5.0.0

- Update requirement
- Make the SkillSettings class hashable

* Update adapt to 0.3.2

* Upgrade websocket-client
2019-02-27 23:41:24 -06:00
Åke 84754668a6
Merge pull request #2018 from MycroftAI/refactor/default-message-vals
Add default values to Message attributes
2019-02-26 16:34:17 +01:00
Åke Forslund be72733abb Fix context checks
- intent_service
- MycroftSkill
2019-02-26 15:46:12 +01:00
Åke 4de2bee18c
Merge pull request #2017 from MycroftAI/feature/first-boot-check
Try updating the system on boot when not paired
2019-02-26 13:53:09 +01:00
Åke ded9f8a11d
Merge pull request #2016 from MycroftAI/feature/ntp-reply
Wait for ntp sync complete message
2019-02-26 10:52:49 +01:00
Matthew D. Scholefield af2b448321 Try updating the system on boot when not paired
This sends a new system.update.check message when the device is booted and not paired
It is not sent every boot because the command could upgrade across major versions which the user could not want.
2019-02-26 02:37:59 -06:00
Matthew D. Scholefield 59ede0de8c Wait for ntp sync complete message
We can easily wait for the message, even if it doesn't exist
2019-02-26 00:55:51 -06:00
Åke b59fa51b1e remove compaitbility methods for installer skill (#2006)
- load_skills_data()
- write_skills_data()
2019-02-25 00:42:06 -06:00
Åke Forslund 40eca55cf2 Expand .voc files in MycroftSkill.voc_match()
- Create a read_vocab_file() function that normal vocab loading and voc_match both uses. This function handles blank lines and comments
- Use a simpler regex instead of word logic to match
- Add a couple of test cases for the method
2019-02-22 18:49:01 +01:00
Steve Penrod eac364f0f8 Fix behavior of MycroftSkills.voc_match()
Previously the voc_match() method had several problems:
* Blank lines in the .voc file would cause it to match all strings
* Comments weren't ignored
* Substrings matched so "book" would match "ok", for instance
2019-02-22 04:25:57 -06:00
Åke 7674fa1c65
Merge pull request #1995 from MycroftAI/feature/settings-cleanup
Clean up some exception handling in settings code
2019-02-18 09:11:01 +01:00
Steve Penrod fb6bde0885 Fix rare settings bug
In the case where a network call during the initialization of the
settings poll fails the first time, it would never be tried again.
Now it will retry initialization once a minute.
2019-02-15 14:48:22 -06:00
Matthew D. Scholefield 64571924e7 Add (|) syntax to dialog and voc files 2019-02-15 12:05:39 -06:00
Steve Penrod 6b80d933ec Handle several other potential failure points
Several API calls weren't surrounded by any error handling.
2019-02-14 17:05:41 -06:00
Steve Penrod a76c3a6e7a Quiet PEP8 2019-02-14 15:49:05 -06:00
Steve Penrod de818db9cb Clean up some exception handling in settings code
The settings code worked, but was noisy and generally messy about
a few exceptional but common situations:
* When the .mycroft/skills/<SkillName> folder didn't already exist
* When network timeouts and such occcurred

I also slipped in a couple trivial code cleanups for an unused variable
and a log message.
2019-02-14 15:41:27 -06:00
Åke Forslund 4a9aae4fea Load the settingsmeta as utf-8
the settings meta is also distributed by skills and should be considered to be utf-8 no matter the system settings.
2019-02-13 21:06:06 +01:00
Alistair Francis edafce059d skills: Open all skill data files as utf8 encoded
Signed-off-by: Alistair Francis <alistair.francis@wdc.com> and Åke Forslund <ake.forslund@gmail.com>
2019-02-13 21:05:18 +01:00
Åke 0a686be7d1 Add a decorator for simply adding idle pages (#1970)
To simplify the process of adding an idle page to a skill the decorator "resting_screen_handler" was added. In a skill class the decorator can be applied to a method to register it to handle idle.

    @resting_page_handler("My Idle Page")
    def handler(self, message):
        ...

The decorator will Register the method with the Mark-2 skill and perform all communications needed to make it work smoothly.
2019-01-31 01:22:33 -06:00
Åke 60ab1aab69 Fix registering fallback (#1974)
The wrong method was registered, instead of the wrapped function call
the original method was registered. This led to not being able to
unregister fallbacks.
2019-01-31 00:21:15 -06:00
Åke 9ef95506d0 GUI update number 6 (#1964)
* Add communication from GUI to skills

- "set" events from Qt will set/update a variable in the skills .gui member
- It's possible to add general event handlers using self.gui.register_handler()
- Moved registration of skill_id to just after skill init

* Ensure that simultaneously writes doesn't occur

Wrap WebSocketHandler.write_message() with a lock in an attempt to handle "buffererror: existing exports of data: object cannot be re-sized."

* Add better logging to help debug disconnect issue

* Allow overriding the idle page

SkillGUI.show_page() and SkillGUI.show_pages() now takes an optional
override_idle parameter. This is used as a hint by the mark-2 skill
and if possible the idle screen will not be shown.

* Improve debugging using Logger

* Raise exception when sending a non-existing gui page

* Restore running state to new connections

When a GUI is connected data and running namespaces are synchronised and
shown.

This refactors the code quite a bit moving the GUI state from the GUIConnection
object to the Enclosure.

The GUIConnection object does the handles the sync in the on_connection_open()
method.

* Add gui.page_interaction message

Currently triggered on page change on the display.

* Handle message when gui changes sessionData

* Check if socket exists on gui before sending data

* Increase port on each failure and retry
2019-01-22 08:45:19 -06:00
Åke Forslund d5f04ada76 Run queries in threads 2019-01-17 12:00:37 +01:00
ludwhe 8b71b89cf8 Better feed back for missing intent/entity files 2019-01-14 08:56:35 +01:00
jarbasal 1c3543f5e5 Support for audio seek
The audioservice can now jump forward and backward in the audio stream/file

The functionality is accessed via the audioservice class's seek_forward(),
seek_backward() and seek() methods
2019-01-12 13:10:54 +01:00
Åke Forslund 38701a9790 Remove inheritance from object
Inheriting from object isn't necessary in python3.
2019-01-11 09:24:21 +01:00
Åke 2e9d764d36 GUI update (#1922)
Several additions to the GUI protocol support

These changes allow switching between pages successfully with the current
mycroft-gui widget:
* Optimized commands to handle the active skill list
* MycroftSkill.gui.show_pages(list, idx) allows multiple-pages to be displayed
  at a time starting with the given index visible.
* Merge SkillGUI.show_page with show_pages
  This limits code duplication and makes things a bit more maintainable.
* Do not reload on changed .qmlc files
* Make EnclosureGeneric derive from Enclosure
* Update show function to match mycroft-gui-app
  - adds internal representation of all loaded skills
  - uses new commands to switch between pages and namespaces
* Add Extra debug output in enclosure
  - Log if starting websocket fails
  - Log the sending of page info in more detail
* Update GUI Debug client in CLI
  - The CLI GUI now handles the new messages for switching pages
  - Handle different data types better by using format instead of string concatenation
* Disable syncing code.
  The sync code at startup outdated and needs to be reworked. Disabling it for now
  to allow better interaction.
* Minor cleanups
  - do not inherit from object
  - use format instead of string concatenations
  - remove duplicated self.loaded
  - correct private member access
* Refactor GUIConnection.show()
   Move the actions into separate methods for better overview of the logic
* Flipped "valid_file" to become "ignored_file"
2018-12-29 21:35:48 -06:00