Commit Graph

92 Commits (10b8e93b7419126864d9bab2effbe813962865ee)

Author SHA1 Message Date
jarbasal 0de7f11c6e execute TTS from debug_cli 2020-02-15 15:35:43 +01:00
jarbasal e57671ebeb capture all in cli 2020-02-15 12:52:23 +01:00
Jarbas-Core d16964c580 bus message targetting 2020-02-15 12:37:25 +01:00
Åke Forslund 2fa81aac52 Disregard DEBUG entry in filter
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".
2019-12-09 08:27:27 +01:00
Steve Penrod 2f4b2ccf48 Remove signal.SIGINT handler from simple CLI
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.
2019-12-03 20:07:19 +01:00
David Wagner b0c7d3072c Update text client parsing of mic_level file 2019-09-25 12:23:11 +02:00
Chris Veilleux cc3ef9b4b0 changed to handle new log message format 2019-08-02 11:16:55 -05:00
Chris Veilleux 0bde1bc9df Refactor skill service (#2220)
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
2019-07-26 08:53:27 +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
Åke fc0a253c28 Fetch CLI log path from config if available (#2192)
* Fetch CLI log path from config if available

* Remove the old log locations
2019-07-11 17:40:40 -05:00
Åke 3b697519d0 Make sure help section shows everything (#2151)
- Use entire screen height
- Correct page number calculation
- Add constants to improve code readability
2019-06-20 17:04:08 -05:00
Åke b4fc3ab389
Merge pull request #2011 from MycroftAI/feature/logging-control
Improve debug logging
2019-02-22 17:37:32 +01:00
Åke Forslund 5ce4754d94 Cleanup of broken and incorrect code
- Fix pep8 in util/__init__
- Remove half done if statement and fix codacy in text_client.py
- CAPITALIZE the log levels
2019-02-22 14:54:28 +01:00
Steve Penrod fbcfe6c816 Improve debug logging
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.
2019-02-22 05:11:16 -06:00
Steve Penrod ed971ed1a9 Fix bug in the mic-level meter
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.
2019-02-22 11:54:00 +01:00
Åke a94019a8b8 Use language set in mycroft configuration (#1925)
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.
2019-01-31 01:38:47 -06:00
Alistair Francis 71afcb9ce5 text_client.py: Don't log stack trace on missing conf (#1957)
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>
2019-01-18 09:59:55 +01:00
Steve Penrod b38668a2ef Fix Ctrl+C handling in CLI
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.
2019-01-17 09:47:43 +01:00
Åke fa5c9abd78 GUI Cleanup (#1939)
* 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.
2019-01-09 20:09:21 -06: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
Steve Penrod 07bd6ef7af Code cleanup
Fixing PEP8 and such before merging into 'dev' branch.
2018-12-03 17:33:26 -06:00
Steve Penrod 0ff744529b * Add tracking of the active namespaces for the GUI. Currently the namespace list
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"
2018-11-30 03:04:53 -06:00
Steve Penrod 685a729994 Enhance CLI GUI client
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
2018-11-23 09:29:16 -06: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
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 2efe3eb9ef Fix Ctrl+C and Ctrl+X in CLI (#1826)
* 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
2018-09-30 11:14:40 +02:00
Åke 0d14e01907 Fix skills listing in CLI (#1759)
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
2018-08-24 00:03:32 -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
Åke Forslund b41d9edc13 Split text client from __main__
- __main__.py keeps the main setup of hiding stderr/out and argument parsing
- text_client.py contains the actual text client
2018-08-16 20:54:05 +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
Åke 13f669d514 Set default encoding in a cleaner way (#1745)
- simplify code setting LC_ALL
- Handle other encodings than utf-8
2018-08-15 17:16:34 -05:00
Steve Penrod 46c92e0c36 Fix CLI lockup; simple 'speak' support; help display
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.
2018-08-14 22:40:08 -05:00
Steve Penrod 1c82945576 Move logs to /var/log/mycroft/ directory
Simplifies permissions and future log-rotations to have all logs
under a single folder instead of having to give permissions to each.
2018-08-02 23:57:13 -05:00
Steve Penrod f329051743 Move logs to /var/log in all cases
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
2018-08-02 21:21:30 -05:00
Steve Penrod 040b64d09d
Fix CLI screen corruption (#1704)
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.
2018-07-30 17:17:48 -05:00
Steve Penrod 223c88b4dd CLI Updates: Restore VT100 support, help, etc. (#1667)
* 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
2018-07-12 09:38:29 +02:00
Åke b1408617bc CLI Feature: skill commands (#1612)
* 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
2018-06-22 00:59:51 -05:00
Åke b57a0ddb65 Use get_wch() to support unicode input in the CLI (#1609)
The CLI interface should now allow non-ASCII characters, including those used in non-English languages.
2018-06-06 17:02:48 -05:00
Matthew D. Scholefield 78a6ec1ceb Fix cli crash with Python 3
This worked in Python 2 because type(4 / 2) == int but in Python 3 type(4 / 2) == float
2018-04-27 08:56:47 -05:00
Åke Forslund a2993e4ba6 Remove backwards compatibility with python 2.7 2018-04-27 08:51:47 -05:00
Åke Forslund d4ba484ad9 Make text client python2/3 compatible
- Make str unicode string
- Use BytesIO for python2 and StringIO for python3
2018-04-27 08:50:46 -05:00
Matthew D. Scholefield cbf73d4b30 SSML Changes
- 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
2018-04-18 14:45:09 -05:00
penrods 0dd337d44c Tweaks to CLI: Refresh, scroll fix
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)
2018-02-23 03:20:23 -06:00
Åke 1578f16897 Make sure the cli locale is set to an UTF-8 type (#1438)
If the locale setting fails add exit with a simple error message suggesting workaround
2018-02-23 03:05:58 -06:00
Zach Welch 49b1a0ca5c issue #1083: limit history size to fix crash (#1436)
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.
2018-02-23 01:54:20 -06:00
Åke 3271ff3e24
Merge pull request #1420 from MycroftAI/feature/cli_declutter
Reduce CLI log clutter from settings, etc
2018-02-15 10:31:51 +01:00
Åke f8fec82905 wait_for_response method for synchronous messagebus communication (#1423)
* 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
2018-02-15 01:39:11 -06:00
penrods 920845c407 Reduce CLI log clutter from settings, etc
* Drop settings INFO messages to DEBUG
* Add DEBUG filter in the CLI by default
2018-02-13 02:40:44 -06:00
Åke 0e3acbada4 add :skills command to list skills in cli (#1395)
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
2018-02-01 02:14:38 -06:00
Matthew D. Scholefield 856fed036b Restore captured text on cli exceptions 2018-01-19 16:46:51 -06:00