The DEBUG, has been filtered by default. This will disregard the DEBUG
filter completely since the same effect can be achieved by setting the
debug level using ":log level debug".
At some point during refactoring the ability to hit Ctrl+C to exit the basic CLI was lost.
The signal.SIGINT handler is needed by the graphical GUI, but it
interfered with the use of sys.stdin.readline() in the simple CLI.
Rearrange the installation of the handler for only the GUI.
To test, run:
mycroft-cli-client --simple
Then hit Ctrl+C. Before this change nothing happens (you just see the "^C" printed out). After the change it exits as expected.
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
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.
Several changes to the logging using in all processes:
* Disable logging of bus messages by default (massively cleans up the logs)
* Add "mycroft.debug.log" bus message. It supports the data={"bus": True/False} as well as
data={"log": LEVEL}, where level is a Python logging level.
CLI now supports several commands:
* ```:log level XXX``` where XXX is the name of a standard Python level (e.g. 'debug')
* ```:log bus on``` or ```:log bus off```
* Removed the requirement for "log" in ```:clear log```. ```:clear``` works now.
The mic-level meter that appears in the Mycroft CLI could stop updating in
rare cases when a file I/O operation failed. It would also fail to show
a meter ever if the mic_level file hadn't been created before the CLI was
started.
Slight refactoring to accommodate for this in a nice way. Created
function connect_to_mycroft() handling fetching the config and
connecting to the mycroft messagebus since these are related and the
order is important to maintain for it to work.
If we are missing the ".mycroft_cli.conf" file we print a message to the
user informing them that we are ignoring the missing file along with a stack trace. The stack trace is really not necessary so this removes it.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Ctrl+C was not being properly handled by the CLI, resulting in an unclean
shutdown and other unexpected consequences -- e.g. a
"./start-mycroft.sh debug" would kill the background processes on exit. The
KeyboardException was never being triggered.
Now the SIGINT is being captured and Ctrl+C behaves (as intended) just like
pressing Ctrl+X.
* Try to improve stability
- Remove sync_active
- Update the way variables are sent to the gui
* Do not show full path for pages
The cli now shows the basename of the current page to make it easier to
determine if the correct page is displayed.
* Make elements in loaded list named tuples
This makes the intent of the code a bit cleaner.
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"
is kept in order, but old namespaces/skills are never culled.
* The active namespace list is synced on a GUIConnection level
* QML display requests now are sent as a list instead of a single entry, i.e.
with "gui_urls" instead of "gui_url". Currently a skill can only send a single
QML, however.
* Change CLI GUI client to handle "gui_urls" instead of "gui_url"
The GUI client built-in to the CLI now has these features:
* Activate/deactivate via Ctrl+G
* GUI 'window' shows active page title and all namespace variables
* Add fool-proof primitive draw(x,y, msg) that takes care of clipping, and padding
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"
* 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
* Fix Ctrl+C and Ctrl+X in CLI
There were several quirks in the shutdown of the CLI client:
* Consumed Ctrl+C wasn't being handled cleanly
* main() got called twice, requiring two Ctrl+Cs to exit
Skills list shared the help screen id it was immediately overwritten by
the help.
- Give the skills page a separate page number
- Replace screen id numbers with simple identifiers
- Add simple handling of multiple pages
Several minor and simple CLI fixes:
* The CLI was locking up with at Lock() deadlock when rebuilding the
filtered log.
* The simple_cli() wasn't registering handle_speak() on the websocket,
even though the handler was setup for it. The utterances are already
clear from the Input: line or from the logs being printed, so no need
to have a handle_utterance() registered in the simple_cli() case.
* Help wasn't refreshing the screen, so was invisible.
* An error could be thrown if Ctrl+Z was hit to suspend the 'fg' to
return to foreground before any key was pressed.
Previously, the location of the log files changed depending
on whether you were running on a Mark1/Picroft or under a
"Github" install. Now they are always under the same directory
at /var/log/mycroft-*.log
This also updates the CLI to pull from that location always.
Additionally:
* Removed the nonfunctional 'wifi' option from start-mycroft.sh
* Made the validation for dev_setup.sh exit instead of just show
a warning message in start-mycroft.sh
* Added code to allow dev_setup.sh to be run from different
directories successfully
The CLI would often have temporary screen corruption. This reworks
several things to correct that issue, although it looks like the
ultimate cause was drawing to the screen while in the middle of
waiting on a VT100 ESC keycode sequence.
* Rearchitected all screen drawing to run in a single thread. Now
call set_screen_dirty() instead of draw_screen()
* Added a lock on accessing the various Log buffers, preventing
changes to the buffer in the middle of a redraw
* Modified key reading logic when ESC character is received. Now
uses a 1 second timeout if no subsequent keycodes are sent
* Catch several special exceptions. Curses throws exceptions in some cases during get_wch(), such as
when you Ctrl+Z suspend the CLI the resume the process. Also moved Ctrl+C processing into this exception handler.
* Restored VT100 function key support
* ESC now clears the entry line
* Spoken commands now become part of the history
* Enhanced help screen with auto word-wrap
* Bugfix: "Show meter" setting didn't persist, now it does
* Update format for skill listing
Now send the skills with id and active status
* Add commands to activate/deactivate skills
* Add "unload all except one" functionallity
* Update after rebasing
- fix identifying skills
* Unload skills if they're removed from disk
* Rename _shutdown to default_shutdown
The method is not intended to be non-public, and this should shut up
codacy bot.
* Handle keep command without argument
* Add new commands to help
- Split help into multiple pages as needed
* Support :activate all
- Engines now specify if they support ssml rather than the configuration
- The text client strips out ssml tags
- Engines can modify tags via the `self.modify_tag` method
Several tweaks to CLI behavior
* The "show/hide meter" setting is now persisted
* Fix behavior when scrolled back and logs are rolling off
* Fix potential crash when no logs exist
* Add Ctrl+R to force a refresh (undocumented for now-- help page is getting long and we need an automated system to resize help for smaller screens)
The calulated limit ensures that at least one message will be displayed.
Using a hard-coded constant is ugly, but such are scattered throughout
the script. Untangling those constants has been left for future patch.
* Add wait_for_response method to Websock client
The client handles the basic case when wanting to do a syncronous
request-response action.
The method sets up a handler waits for the response and handles timeout.
The expected format is that the reply message should have the same type as
the original message with ".response" appended.
An method in the Message class has been added to create a standard response for
a message.
* Let the :skills command use wait_for_response
* Minor docstring changes
Fixed typos and refined text
SkillManager now handles the skillmanager.list message and will reply with the
mycroft.skills.list message including a list of the loaded skills.
==== Protocol Notes ====
Added messages:
- skillmanager.list: skill manager send list of skills on messagebus
- mycroft.skills.list message with skill list