Commit Graph

728 Commits (644d75cfc95f02093211a04c31bdb27b8f38feea)

Author SHA1 Message Date
Å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