Commit Graph

709 Commits (a67a60a8eb7b71ed626ff9852bd7b9e3033ec26e)

Author SHA1 Message Date
Åke Forslund bf390bcac9 Fix typos in CommonPlaySkill docstrings 2018-11-16 11:50:48 +01:00
Åke Forslund 18f7bb707f Add docs for some MycroftSkill members of interest 2018-10-29 20:09:26 +01:00
Åke Forslund 25e9eb12c0 Fix issue listing uninstalled skills in skills.json
All skills known by msm was added to the skills.json, this makes sure only local skills are added
2018-10-26 12:59:52 +02:00
Åke a90aa26803
Merge pull request #1859 from MycroftAI/feature/skill_data_upload
Feature/skill data upload
2018-10-26 10:36:43 +02:00
Åke Forslund 7666acea58 Fix updating beta skills
"HEAD" doesn't actually update to latest remote head to make the update work None is needed.
2018-10-25 14:56:48 +02:00
Åke Forslund 9bcddaf69a Upload skill manifest on write
- Convert skills.json format to new representation and upload
- Store skill installation time when installing defaults
2018-10-24 22:11:35 +02:00
Åke cab63efa5a Support detach_skill in padatious_service (#1846)
The registered intents are now stored in a list. When a detach_skill message is received the list is checked for matching intents and the intents are removed
2018-10-24 10:26:06 -05:00
Åke Forslund b1f2ff27a0 make CPS_Start not override utterance parameter
If an utterance is provided already the method shall not try to override it with a stored utterance.
2018-10-23 18:31:19 +02:00
Åke Forslund 6dcb6a4290 Handle utterances set to None in play()
play would happily send on None to the audioservice even though it's not a proper sentence. This will handle None and default it to an empty string.
2018-10-23 18:21:10 +02:00
Åke 792a70ebeb
Merge pull request #1843 from MycroftAI/feature/commonplay
Add CommonPlaySkill, unifying search and control
2018-10-11 07:44:33 +02:00
Steve Penrod 2de0859bfc Updated based on review feedback
* Renamed methods (removed odd double-underscore)
* Change CPS_play() to take variable arguments
2018-10-10 16:31:49 -05:00
Michael Nguyen 6289bb5b50
Merge pull request #1835 from forslund/refactor/skills-core
Cleanup of core.py
2018-10-10 11:08:37 -05:00
Steve Penrod 4ca6c09d64 Quiet automated tests 2018-10-10 03:02:20 -05:00
Steve Penrod 69cc1b9283 Add CommonPlaySkill, unifying search and control
The CommonPlaySkill base class provides an easy base class for any
skill wishing to use the "Common Play" framework.  This allows multiple
skills to jointly handle requests such as "play Janet Joplin",
"play my Sled Zepplin playlist", "play NPS news" or "play Strump's
speech to the UN".  Previously the "wildcard" intents needed to handle
this were basically impossible -- only one skill got a shot at handling
the request.  Now several skills to search their service to see if they
have anything that can service the request.  The service with which
reports the highest confidence gets invoked.

The CommonPlaySkill makes it easy to implement this.  Simply derive a
skill from CommonPlaySkill (instead of MycroftSkill) and override
the two required methods CPS__match_query_phrase() and CPS__start().
The skill can then use self.CPS__play(url) to begin playback, or invoke
a unique player to interact with a custom service.
2018-10-09 21:02:29 -05:00
Åke 83e1ed1d3c
Merge pull request #1815 from JarbasAl/feature/cross_context
feature: allow adapt context across skills
2018-10-08 22:57:04 +02:00
Åke Forslund b761f02dfb Make ContextManager handle cross intent context
This makes a cross context call be treated as one level when calculating the probability. this makes previous contexes not be completely invalidated when a cross context call is sent.
2018-10-08 14:17:52 +02:00
Åke Forslund cce610b57e use nonlocal in get_scheduled_event_status() 2018-10-07 08:56:26 +02:00
Åke Forslund c06a4711a5 Minor restructurings
The most notable things:
- Use the new wait flag when calling speak
- Fix except without defined exception
2018-10-07 08:56:07 +02:00
Åke Forslund bd76379e5c Improve readability of get_handler_name() 2018-10-07 08:55:58 +02:00
Åke Forslund edaa2cb0af Make load_skill slightly more compact 2018-10-07 08:55:49 +02:00
Åke Forslund b163944437 Move trace formatting to separate function
The new simple_trace() function can now generate a simplified stack trace instead of doing it inline in the MycroftSkill class
2018-10-06 21:41:32 +02:00
Steve Penrod 0d64e78d0c Add protection for naive skill authors (#1825)
* Add protection for naive skill authors

It is fairly common for new skill authors to attempt actions in the __init__()
method which are not legal yet, as the Skill has not been fully connected to
the Mycroft system.  This adds an @property protection layer for the two most common
issues:
* Accessing MycroftSkill.bus
* Accessing MycroftSkill.enclosure

Now those are properties instead of variables and provide appropriate warnings
when used before they exist.

Also enhancing the handling of error logs in the CLI to highlight problems such
as this:
* Color "- ERROR -" log messages in red
* Retaining leading characters from log messages, improving readability in formatted messages
2018-10-01 21:41:48 +02:00
Steve Penrod edb126ca44 Fixed typo and updated comments on schedule_event 2018-10-01 12:29:28 +02:00
Steve Penrod 6181fe1484 Reduce much of the noise in the logs (#1819)
This eliminates a lot of the noise in the log files.  Later I'll add features in the CLI to
assist watching the messagebus messages rather than writing them all to logs.

Also corrected some language and formatting in settings.py docstrings.
2018-09-28 12:48:34 +02:00
Åke 2e7179d661 Strip trailing blank lines (#1817)
If a blank line is intended add a single space and it will be included
2018-09-26 22:22:00 -05:00
Steve Penrod 3843f5a657 Add "wait" option to MycroftSkill.speak() and speak_dialog() (#1812)
* Add "wait" option to MycroftSkill.speak() and speak_dialog()

The new "wait" option will cause the speak function to block until all
of the given dialog has been spoken by Mycroft.  This means:
    self.speak("Hello world", wait=True)
is now equivalent to:
    self.speak("Hello world")
    wait_while_speaking()
2018-09-26 22:02:56 +02:00
Steve Penrod 4a8e0e9f4a Add ability to schedule event in seconds (#1813)
* Add ability to schedule event in seconds

The MycroftSkill.schedule_event() method now accepts an integer in addition to
a datetime for the 'when' parameter.  The integer represents the number of
seconds in the future to fire off the event.  E.g.
```python
   self.schedule_event(some_handler, 7)
```
Will invoke some_handler() seven seconds from now.

Also unified language used in event docstrings.
2018-09-26 21:35:14 +02:00
jarbasal f1e8f6922c remove context methods 2018-09-26 20:10:34 +01:00
jarbasal 20b87eeac3 pep8 2018-09-26 19:27:05 +01:00
Steve Penrod fb03ac6cec Order results from translate_namedvalues()
Switch to an OrderedDict() for translate_namedvalues(), maintaining the
sequence of values defined in the original "list.value" file.  This is
useful in circumstances where there are multiple values, but the order
of listing indicates some sort of preference.

This is used in the Alarm skill to allow synonyms like "weekdays"/"weekday",
"Mondays/Monday", but the first value is used when building the status string.
For example "You have an alarm for 8am on Mondays".  Generically, this lets
translators consistently provide preferred names for values by adjusting the
order.
2018-09-26 13:26:56 -05:00
jarbasal efd184fd19 word arg is optional 2018-09-26 19:25:25 +01:00
jarbasal d9b946a22f allow adapt context across skills 2018-09-26 19:18:08 +01:00
Åke 1ad41ef5ec Workaround for adapt issue with context + one_of (#1789)
Adapt doesn't populate the entry from the one_of correctly from context. To work around the issue intent structure is scanned for empty keys and tries to populate them from entities in __tags__
2018-09-24 15:17:13 -05:00
Åke f091f44c85 Audioservice repeat (#1805)
* Add repeat option to audioservice

The audioservice.play() method now accepts a repeat parameter. If this
parameter is True the playlist passed to the audio service will be
repeated.

* Add repeat support to vlc

* Add the repeat parameter to all services

Not functional but playback will work at least. Hacktoberfest?
2018-09-24 15:12:12 -05:00
Åke 0ed9450ca7 Bugfix/skill loading remnants (#1783)
* Add cleanup if the skill loading fails

If a skill throws an exception in initialize the registered handlers
need to be removed. To cleanup this the skill shutdown procedure is
run.

* Don't try converse method on non-loaded skills

Checks if a valid skill instance is present before calling the converse method
to filter out skills that wasn't loaded.

* Mark unloaded skills as inactive in CLI
2018-09-09 02:04:06 -05:00
Steve Penrod c13b40fc25 Fix path in recent locale support
The recent changes to support the 'locale' directory were incorrectly
joining the os.walk() path and filename, resulting in double-directories,
like "./vocab/en-us/./vocab/en-us/Something.voc"
2018-08-29 03:54:30 -05:00
Åke 787ff63d2b Remove trailing references to MycroftSkill.emitter (#1768)
- references in skill_tester.py
- when going through the methods to check for decorations the emitter
was triggered and generated a Warning
2018-08-28 12:26:46 -05:00
Steve Penrod e1ab1c2a47 Merge branch 'feature/simple-audio' of git://github.com/forslund/mycroft-core into forslund-feature/simple-audio
# Conflicts:
#	mycroft/audio/services/simple/__init__.py
2018-08-27 14:32:45 -05:00
Åke 85ae69597b Separate enclosure api from enclosure client (#1760)
This is a step towards abstracting the idea of an Enclosure which ties Mycroft to the hardware that is running Mycroft.

- Move the enclosure API to mycroft.enclosure.api (previously was mycroft.client.enclosure.api)
- Move display_manager out of enclosure client to mycroft.enclosure.display_manager
- Merge EnclosureWeather into EnclosureMouth
- Wrap display manager in a class
2018-08-27 13:44:12 -05:00
Åke 7c6ddb0847 Fix voc_match_cache member (#1765)
Seems like a rebase/merge moved this one around. It's now moved back into
__init__
2018-08-27 12:58:15 -05:00
Steve Penrod a3f1179897 Unify vocab/regex/dialog under new 'locale' directory
* Add MycroftSkill.find_resource() that locates a localization resource file
  from either under the old vocab/regex/dialog folder, or under any folder in
  the new 'locale' folder.  The locale folder unifies the three different
  folders and allows arbitrary subfolders underneath it.
* MycroftSkill.speak_dialog() will now speak the entry name if no dialog file
  is found.  Periods are replaced with spaces, so
  ```self.speak_dialog("this.is.a.test.")``` would return "this is a test" if
  no file named this.is.a.test.dialog is found.
* Remove MycroftSkills.vocab_dir value
* Minor edits to several docstrings
2018-08-27 13:28:46 +02:00
Åke 1d4297d33c Remove announcement parameter from get_response (#1758)
MycroftSkill.get_response() now uses the dialog parameter as either a literal string or a dialog
filename.
2018-08-26 01:56:26 -05:00
Åke 3334316c63 Add MycroftSkill.voc_match (#1719)
The method first tries to use the skill vocab directory and then tries
the mycroft/res/text... directory.

After the vocab is loaded from file once it's stored in a cache
dictionary and further uses of the method won't hit the disk.

Example:
   if self.voc_match(utt, "Yes):
       ...
2018-08-24 20:14:44 -05:00
Michael Nguyen b3c767d912 Web setting typecasting
The initial implementation of web settings returned values as
strings all the time, even Boolean and numeric values.  This
required unnecessarily complicated code, such as:

```python
    if setting["show_time"] == "true":
        # do whatever...
```

Now a value defined in metadata as a "checkbox" gets cast to a boolean,
and values defined in metadata as a "number" is typecast to int or
float, as appropriate.  This allows cleaner code such as:

```python
    if setting["show_time"]:
        # do whatever...
```

NOTE: This can be a breaking change, verify you skill which uses 'checkbox'
webUI types handles this correctly for 18.08.
2018-08-23 23:22:13 -05:00
Åke Forslund 7b4c6ed583 Audio service mimetypes
Add possibility for mimetypes to be passed with each track.
Make simple audio service try to detect mime type if missing
2018-08-23 08:41:01 +02:00
Åke 4aac668a2f Remove depreciated ScheduledSkill (#1731)
- remove the scheduled_skills module
- remove the time_rules module
- remove parsedatetime requirement (only used in scheduled_skills)
2018-08-21 20:53:52 -05:00
Åke 64476eb143 Replace emitter/ws with bus (#1757)
Makes the code a bit more understandable
2018-08-21 20:50:50 -05:00
Matthew D. Scholefield c138fda79e
Merge pull request #1725 from forslund/feature/__main__
Feature/__main__
2018-08-21 10:29:13 -05:00
Åke 4e8972669f
Merge pull request #1750 from MycroftAI/bugfix/removing-scheduled-events
Fix removing scheduled events
2018-08-17 12:35:53 +02:00
Steve Penrod 6838e10965 Fix removing scheduled events
The list holding the names of scheduled events was being populated with decorated names,
but other code assumed it held the "friendly" name.  Corrected this assumption.

Several locations also removed list entries while iterating on the same list, resulting
in entries being skipped and left un-deleted.  This left behind phantom scheduled events
when skills were reloaded, goofing up many schedules after the reload.
2018-08-17 04:48:34 -05:00