Commit Graph

106 Commits (5f4c68e5831e668f11dddc9a2d00bf11698f8c5b)

Author SHA1 Message Date
Bart Ribbers e20443b824 Use XDG Base directories for settings, cache and runtime data
Improve deprecation warning message
2021-08-05 10:04:45 +02:00
Åke Forslund 9acf5b7592 Utilize the mycroft-messagebus-client module
This utilizes the shared messagebus client implemented in the
mycroft-messagebus-client.
2021-03-22 06:31:50 +01:00
Åke Forslund 0a9de0ab7c Update to pyee 8.1.0
pyee 8.1.0 adds a small change to make the once call to be more safe in
multithreaded environments.

This switches back from the now deprecated BaseEventEmitter to the
standard EventEmitter.
2020-10-22 11:43:06 +02:00
Kris Gesling ac8e10898f remove deprecated ThreadedEventEmitter 2020-08-18 16:00:51 +09:30
Kris Gesling d70c425854 switch deprecated EventEmitter to other classes 2020-08-18 15:58:42 +09:30
Kris Gesling a5b7f55ae4
Merge pull request #2634 from forslund/bugfix/wait-for-response-timeout
Fix custom timeout for wait_for_response()
2020-07-29 07:03:15 +00:00
Åke Forslund 236a2ed594 Add hook for stopping 2020-07-22 11:06:47 +02:00
Åke Forslund 09b1deb511 Add possibility for notification hooks for services
- skills
- audio
- speech client
- messagebus service
- enclosure

The main functions now accepts the arguments ready_hook and error_hook
allowing a service or runner script to catch these states and perform
actions accordingly.

This is useful for things like systemd or a desktop launcher.

Fix audio service startup
2020-07-22 10:52:27 +02:00
Åke Forslund cba284e4a0 Fix custom timeout for wait_for_response()
The method didn't forward the selected timeout and only the default wait
was ever used.
2020-07-10 09:11:35 +02:00
Kris Gesling b0c34cba97
Merge pull request #2507 from forslund/feature/pyee-7
Update pyee to v7.0.1
2020-07-09 16:10:00 +09:30
Åke Forslund 928e1a8b33 Mark ThreadedEventEmitter as depreciated 2020-07-07 08:36:57 +02:00
Åke Forslund 0fc1ba325a Update pyee to v7.0.1
pyee has added ThreadExecutor variant of the EventEmitter which can
replace the home-spun threadpool based emitter
2020-07-07 08:21:42 +02:00
Åke Forslund b7d709c3c8 Add wait_for_message() method to messagebus client
- Refactor message waiting into a MessageWaiter class to be able to use the
  same code in both wait_for_message and wait_for_response.
- Add some basic unittests
2020-07-05 09:28:17 +02:00
Åke Forslund 29f60e6d66 Clean up the wait_for_response method
- Use nonlocal instead of mutable object.
- Set default timeout in method argument
2020-07-05 09:28:17 +02:00
Åke Forslund d30f778026 Make message.response keep source/dest info 2020-02-24 10:37:10 +01:00
Åke Forslund aad961f1b5 Copy message context on reply
This ensures that the original context isn't modified, for example when
converse is used the reply there would switch the source/destination for
the original message making the skill speak to the wrong destination.
2020-02-21 07:57:46 +01:00
jarbasal fc9e254eef common iot message context 2020-02-15 15:35:43 +01:00
Jarbas-Core d16964c580 bus message targetting 2020-02-15 12:37:25 +01:00
Åke Forslund 3aea18c7be fix remove_all_events
The threaded event emitter did not remove the wrapper mapping when
remove_all_events were called causing trailing references to objects.
2019-10-31 09:42:24 +01:00
Åke Forslund 39a38bc641 Move send function away from __main__ file
This resolves the Runtime Warning "'mycroft.messagebus.send' found in sys.modules after import of package 'mycroft.messagebus', but prior to execution of 'mycroft.messagebus.send'; this may result in unpredictable behaviour"
2019-10-29 09:14:49 +01:00
Åke Forslund 0811df3831 Don't load remote settings for send command 2019-10-25 14:04:23 +02:00
Åke Forslund 146c3cad0c Log bus messages with debug level 2019-09-06 13:31:32 +02:00
Åke Forslund 43ed3a99a8 Make messagebus service respect loglevel 2019-09-06 13:29:40 +02:00
Åke Forslund 3b2c7267e7 Rename Message type arg to msg_type
Name change to remove collision with the builin type.
2019-09-02 13:30:55 +02:00
Åke Forslund e2d5b92bfe Remove deprecated methods and checks 2019-09-02 11:45:32 +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
Åke Forslund 4034745340 Restore build_url static member to messagebus client 2019-07-24 08:49:44 +02:00
Chris Veilleux edcc1c261e simplified super() call to use Python 3 syntax 2019-07-19 08:16:55 +02:00
Chris Veilleux 2c67381aee added module level docstring 2019-07-19 08:16:55 +02:00
Chris Veilleux be3dff99a1 added licence info to files without it and a missing docstring 2019-07-19 08:16:55 +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
Chris Veilleux 3efce9639e Clean up of messagbus/send.py
- reorder imports
- refactor docstrings for consistency
- rename camel case variables to use snake case
2019-07-19 08:16:54 +02:00
Chris Veilleux 7a7ed8944d Clean up of message.py 2019-07-19 08:16:54 +02:00
Chris Veilleux 468fb800a7 refactor messagebus service:
- add some docstrings
- put config retrieval in a function
- add log messages
2019-07-19 08:16:09 +02:00
Åke Forslund 1400af2b16 Fix pycodestyle errors 2019-05-15 13:46:43 +02:00
jarbasal e256e3d1a6 restore bus on_message 2019-04-16 23:28:51 +01:00
Åke 07c2a93324 Feature/threaded emitter for real (#2024)
* Run emitter using threadpool

This moves the thread pool from the websocket client into the eventemitter allowing each registered function to run in a separate thread and not just each event.

This speeds up cases where there is a one to many call such as the common play framework and the upcomming common query framework.

* Add unit tests for threaded event emitter

* Add standard header

* Add standard header
2019-02-28 03:04:51 -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
Matthew D. Scholefield 42ea785fd8 Add default values to Message attributes
This ensures no attributes are None and simplifies some checks within the function
Otherwise, if, for instance, there were no 'data' field in a message, when deserializing, the caller would have to check for None
2019-02-26 02:44:19 -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 f106f9603f Revert "Merge pull request #1889 from forslund/feature/threaded-emitter"
This reverts commit cb891ecf2f, reversing
changes made to 876b5393f7.
2019-01-17 11:11:43 +01:00
Åke Forslund 555031762a Run emitter using threadpool
This moves the thread pool from the websocket client into the eventemitter allowing each registered function to run in a separate thread and not just each event.

This speeds up cases where there is a one to many call such as the common play framework and the upcomming common query framework.
2019-01-14 07:29:43 +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 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 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
jarbasal 4e3667e21c Only replace complete words in message remainder
Replace str.replace() with simple regex
2018-11-17 08:35:40 +01: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
Steve Penrod 496c0d1134 Fix Codacy warning... 2018-08-27 16:31:31 -05:00
Steve Penrod 741bd92a26 Fix PEP8 issue created by accidental code merge
Some debugging code got mixed in the merge for #1761, creating a PEP8 error
2018-08-27 16:16:22 -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