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.
pull/2409/head
Steve Penrod 2019-12-02 17:54:44 -06:00 committed by Åke Forslund
parent 21699294c7
commit 2f4b2ccf48
2 changed files with 5 additions and 5 deletions

View File

@ -13,13 +13,15 @@
# limitations under the License.
#
import sys
import signal
import io
import os.path
import curses
from mycroft.util import get_ipc_directory
from .text_client import (
load_settings, save_settings, simple_cli, gui_main,
start_log_monitor, start_mic_monitor, connect_to_mycroft
start_log_monitor, start_mic_monitor, connect_to_mycroft,
ctrl_c_handler
)
from mycroft.configuration import Configuration
@ -57,6 +59,8 @@ def main():
sys.stderr = sys.__stderr__
simple_cli()
else:
# Special signal handler allows a clean shutdown of the GUI
signal.signal(signal.SIGINT, ctrl_c_handler)
load_settings()
curses.wrapper(gui_main)
curses.endwin()

View File

@ -14,7 +14,6 @@
#
import sys
import io
import signal
from math import ceil
from .gui_server import start_qml_gui
@ -121,9 +120,6 @@ def ctrl_c_pressed():
return False
signal.signal(signal.SIGINT, ctrl_c_handler)
##############################################################################
# Helper functions