Commit Graph

888 Commits (3fea4b1e6fa2d3bfd6f620fcd3e188feb4903780)

Author SHA1 Message Date
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
Michael Nguyen 3bb15bc3c8
Merge pull request #1900 from forslund/feature/common-qa
Common query framework
2018-12-05 14:13:01 -06:00
Åke 60462d8979
Merge pull request #1899 from MycroftAI/feature/gui
First pass at the GUI infrastructure
2018-12-05 09:23:08 +01:00
Steve Penrod 1e5ff1392f Feedback from code review
Several small changes based on the code review feedback:
* Drop '_' from classes like Enclosure_Mark1
* Adopt Python 3 style for class definitions and don't explicitly list '(object)'
* Slightly better documentation
* Moved MycroftSkill.show_html() to SkillGUI, resulting in code like self.gui.show_page('Weather.qml')
* Renamed SkillGUI.__dict to SkillGUI.__session_data.  This better reflects the
  how values are accessed in the QML.
2018-12-05 01:40:43 -06:00
Åke Forslund 7036c19bfc Add posibility to give bonus for visual skills
CQSVisualMatchLevel can be returned and if the device is a mark-2 a bonus will be given to the skill.
2018-12-04 23:47:52 +01:00
Åke Forslund 5b168c753b Add CommonQuerySkill class
Adds support for negotiating best answer for a questions

Currently three levels of confidence are defined

EXACT: If the query could be identified exactly and a response is returned.
    Example: The cockail skill could find a cocktail in the query that exists in
             it's database.

CATEGORY: A category of questions the skill handles could be identified.
    Example: The wiki-data skill can identify that the question is regarding
             A date of birth and finds an answer.

GENERAL: A general question and answer service could parse the question.
    Example: The wolfram alpha skill got a match for "How tall is Abraham
             Lincoln".
2018-12-04 22:58:25 +01:00
Steve Penrod 07bd6ef7af Code cleanup
Fixing PEP8 and such before merging into 'dev' branch.
2018-12-03 17:33:26 -06:00
Steve Penrod 54daa84786 Support non-translated resources, QML under 'ui' folder
The QML files are typically not translated like other Mycroft resources,
they have internal translation tools.  And at times there are other
resources that don't need to be translated all the time, for example
color strings like "AliceBlue" which might be used by non-English
speakers.

So now the translation mechanism looks for resource file X as follows:
1) Look for <res_dir>/<lang>/X
2) Look for <res_dir>/X
3) Look for anywhere under locale/<lang>/.../X

And now the show_page() method starts looking for resources under the skill/ui folder.
2018-11-30 16:26:01 -06:00
Åke Forslund 9364b69834 Always use a fresh msm instance
- Use a fresh msm instance to  automatically load the skills_data
- write skills_data.json is now automagic so explicit write isn't needed.
2018-11-29 16:45:31 +01:00
Åke Forslund ec63492628 Add backwards compatibility
Make sure the older version of the install skill will still work. The SettingsManager.load/write_skills_data() will return the version 0 format of the skills_data and the write_skills_data() will convert to the version 1 format before doing the write.
2018-11-29 16:44:58 +01:00
Åke Forslund 8167396eb9 Add skills.json handling through msm
- Lock msm when doing an update
- Add device enpoint for uploading skills.json
- Add configuration value for skill store updates
- Upload skills manifest after update
2018-11-29 16:44:58 +01:00
Steve Penrod b9fb463727 Fleshing out GUI mechanisms, CLI "GUI"
Further fleshing out of the GUI mechanisms
* Support for data and page from Mycroft -> GUIConnection
* Add a 'reconnecting' event for the messagebus
* Add MycroftSkill.show_url()
* Plumb MycroftSkill.gui into the messagebus
* Implement MycroftSkill.gui dictionary

CLI extensions for the GUI:
* Can now act as a simple GUIConnection
* Minor revamp of messagebus connection, provides kinder handling when
  messagebus isn't found or ready.
* BUGFIX: An empty filter would filter ALL messages
* BUGFIX: Input wider than the screen would cause a crash
* BUGFIX: "filter" or "find" with no param would filer "filter" or find "find"
2018-11-21 02:05:28 -06:00
JarbasAI 29310363d7 fix converse (#1884)
- Fix Exception on non-existing instances crashes the handle_converse_request()
- Report error to intent service
- Cleanup of converse related code.
2018-11-20 14:31:49 +01:00
Åke Forslund bf390bcac9 Fix typos in CommonPlaySkill docstrings 2018-11-16 11:50:48 +01:00
Steve Penrod dbd3675156 Fixing a few bugs and adding test code to fire up a weather skill visualization upon GUI connection.
Still very much a work in progress.

For understand and testing, here is the sequence:

STEP 1:  GUI announces itself
* Connect to the main Mycroft messagebus
* Send:  "mycroft.gui.connected" with data { "gui_id": XXX } where XXX is a uniq ID (uuid)

STEP 2:  Mycroft creates GUI socket
* Mycroft extracts the gui_id
* Mycroft prepares a socket and announces its availability on the Mycroft messagebus with:
        self.bus.emit(Message("mycroft.gui.port",
                              {"port": self.GUIs[gui_id].port,
                               "gui_id": gui_id}))

STEP 3:  GUI connects
In python, a very minimal test socket handler on the GUI side would look like this

  from websocket import create_connection

  port = 18181 (from the message above)
     ws = create_connection("ws://0.0.0.0:"+port+"/gui")

  ws.send("Hello, World")
  print("Sent")
  print("Receiving...")
  result =  ws.recv()
  print("Received '%s'" % result)
  ws.close()
2018-11-07 11:06:57 -06:00
Steve Penrod aede71db86 First pass at support for the Qt/QML display:
Enclosures
* Create a mechanism to instantiate unique Enclosure classes, depending on the platform found in the SYSTEM mycroft.conf
* Implement a generic Enclosure, which support the new GUI protocol
* Implement a Mark 1 Enclosure (expects the serial connection to an Arduino)
* Implement the start of a Mark II enclosure
* Implement a generic enclosure (no screen)
* Implement the GUI announcement and protocol basics

MycroftSkill
* Implement the basis of the GUI-controlling interfaces.  Namely:
  - MycroftSkill.show_text()
  - MycroftSkill.show_image()
  - MycroftSkill.show_html()
  - MycroftSkill.show_page()
  - MycroftSkill.gui to set values for page displays.

Configuration
* Add "gui_websocket" to the mycroft.config.py
2018-11-06 01:48:16 -06: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
Åke Forslund b03e0336ca Move SkillManager from __main__ to separate file 2018-08-16 20:53:27 +02:00
Åke Forslund a66e23d8ab start processess using python -m
- rename process main.py to __main__.py
- update start-mycroft.sh/stop-mycroft.sh scripts to reflect the change
2018-08-16 15:21:22 +02:00
Matthew Scholefield e26904e814 Add feature to install beta skills 2018-08-15 14:06:12 -05:00
Julien Kassar 24a80d60c3 Fix camel case splitting
Signed-off-by: Julien Kassar <github@kassisol.com>
2018-08-12 14:00:28 -04:00
Steve Penrod 609a09bbf3
Allow Padatious to override Adapt (#1713)
Allow a Padatious intent to override Adapt when it is VERY
certain that the utterance is directed at it.  (95% confidence
or greater.)  Right now that only occurs if the intent match
for the given phrase is perfect.

This solves this kind of issue:
* Adapt:  Matching on "Set" and "Alarm"
* Padatious: Handling "is an alarm set"

* Fix logic error for when no Padatious intent
2018-08-03 14:43:17 -05:00
Matthew D. Scholefield d49d991a84 Remove git locks when starting mycroft (#1715)
This is a preventative measure to fix errors with git lock files not being removed when devices are unplugged or processes are killed
2018-08-03 14:41:51 -05:00
Steve Penrod ec73b7d48e
Fix named event scheduling/deleting (#1705)
While working on the Alarm skill I discovered several issues with the
event scheduler.  This PR cleans up those findings and resolves several
other potential issues:

1) To avoid thread synchronization issues, the EventScheduler had several
queues which independently held objects to be added/deleted/updated.  However, the order of the events was undefined and got mixed since they were all batched together.  So, for instance, if skill code performed:
   self.add_event("foo", self.handle_foo)
   if SomeReason:
       self.cancel_event("foo")
The actual order of queue handling would perform Remove first, then Add which resulted in "foo" not being found for delete, but then added and left as an active event.

Now the EventScheduler protects the list using a Lock and the queues have been removed.  Modifications to the list happen immediately after obtaining the lock and are not batched up.

2) One-time events were triggered while the event was still in the EventScheduler list.  Now the entry is removed before invoking the handler.

3) Within the MycroftSkill.add_event(name, handler) is a local 'wrapper' method that actually makes the callback.  The MycroftSkill.remove_event(name) method attempted to find entries in the events list and the associated handler entries in the self.emitter to remove.  However, the emitter actually held the wrapper(handler), not the handler itself.  So the emitter handlers were left behind.

This was a quiet bug until the next time you scheduled an event of the same name.  When that second event finally triggered, it would fire off both the new and the old handler -- which snowballed in the 'skill-alarm:Beep' case, doubling and redoubling with every beep.

Now this cancels all the emitter listeners by name.  There is a very slim chance that someone has registered a listener with the same name, but since it is namespaced to "skill-name:Event" I think this is pretty safe.


Not technically related, but a failure that has been lurking for
some time and is a French unit test that doesn't work depending
on the time of day when the test is run.
2018-07-30 15:08:13 -05:00
Matthew D. Scholefield 3fbe12cc07
Make single thread log nicer 2018-07-26 18:57:36 -05:00
Steve Penrod 0eb29718f3 Remove commented-out code 2018-07-26 18:27:49 -05:00
Steve Penrod edc6ab1ed6 Immediately speak warning while Padatious trains
At startup, Padatious was blocking in the fallback while the
training occurred.  As a result, any attempts to use Mycroft
during that period would queue up rather than giving the
user feedback.  Now it immediately returns False, allowing
user notification to occur elsewhere.
2018-07-26 18:21:48 -05:00
Åke Forslund b60320bcae Fix updating padatious intents after intent reload
Training is called from wait_and_train with None as message, this commit adds propper handling for this case.
2018-07-19 14:06:58 +02:00
Åke c140d5b889
Merge pull request #1690 from MycroftAI/feature/ask-yes-no
Add new MycroftSkill.ask_yesno() method
2018-07-19 09:34:32 +02:00
Åke ad5ebcf63d Bugfix/unmunge (#1688)
* Fix cases where the unmunge misses keywords

The unmunge would invariably miss keys due to the fact that the dict is modified while being iterated. This breaks out the keys into a list before iterating through them to ensure that all original keys are checked.

* Clean up the unmunge function slightly
2018-07-19 02:03:43 -05:00
penrods b005ba6f59 Allow dialog param of get_response() to be a spoken string
This makes the dialog parameter dual-purpose.  It can be used as a
literal spoken string, or a dialog resource.  In the future the
announcement parameter can be retired.
2018-07-19 02:00:17 -05:00
Matthew D. Scholefield 0540229cc4
Merge branch 'dev' into feature/cleanup-setup 2018-07-18 10:44:41 -05:00
penrods 18ab343b80 Add new MycroftSkill.ask_yesno() method
New function allows simple yes/no queries to be asked, capturing common
affirmations (e.g. "yes", "yeah", "yep", "sure", ...) and rejections
("no", "nope", ...) that are consistent across all skills.

The method will return a normalized 'yes', 'no' or whatever else is spoken
for further parsing.  None is also possible.

This also adds the MycroftSkill.is_match() method to assist in matching
translated synonyms within an utterance.
2018-07-17 01:35:55 -05:00
Åke 9c8c6b8852
Merge pull request #1686 from JarbasAl/feature/padatious_enable_disable
Make it possible to enable/disable padatious intents
2018-07-14 11:52:12 +02:00
JarbasAI 0e121f8bcd allow disabling intent registered with decorator in initialize (#1685) 2018-07-14 11:36:16 +02:00
Åke Forslund fad890ff39 Clean up setup scripts
- Remove setup scripts for mycroft-skills-sdk since it's not used anymore
- Rename mycroft-base-setup.in/MANIFEST.in to setup.py and MANIFEST.in
- Remove skill-container, since it hasn't been used or kept up to date since 17.08 and the cli commands to remove and activate skills is easier to work with

==== Environment Notes ====
Small update of the packaging script is needed due to this change
2018-07-14 08:36:50 +02:00
jarbasal 56efe5e489 padatious enable/disable 2018-07-14 04:31:39 +01:00
jarbasal c4cdb85599 padatious enable/disable 2018-07-14 04:00:21 +01:00