Support for Mark 1 SSH > BLOCK menu item

This implements the handler for the Mark 1 menu item SSH > BLOCK (the inverse of SSH > ALLOW)
* Added handler for "unit.disable-ssh" on the serial line. This turns around and emits "mycroft.disable.ssh" on the messagebus.
* Removed the automatic reboot, just let the user know it will be different after a restart
* Made the spoken message translatable
* Changed mycroft.dialog.get() to not require the "lang" parameter.  It will default to the mycroft.conf value.
pull/754/head
penrods 2017-05-08 13:37:18 -07:00 committed by Augusto Monteiro 'Sparky
parent 317b497d5f
commit 1b200089c0
5 changed files with 18 additions and 6 deletions

View File

@ -24,6 +24,7 @@ from threading import Thread, Timer
import serial
import mycroft.dialog
from mycroft.client.enclosure.arduino import EnclosureArduino
from mycroft.client.enclosure.eyes import EnclosureEyes
from mycroft.client.enclosure.mouth import EnclosureMouth
@ -80,7 +81,7 @@ class EnclosureReader(Thread):
self.ws.emit(Message("enclosure.start"))
if "mycroft.stop" in data:
create_signal('buttonPress') # FIXME - Must use WS instead
create_signal('buttonPress')
self.ws.emit(Message("mycroft.stop"))
if "volume.up" in data:
@ -138,7 +139,7 @@ class EnclosureReader(Thread):
shell=True)
self.ws.emit(Message("mycroft.wifi.reset"))
self.ws.emit(Message("speak", {
'utterance': "This unit has been reset"}))
'utterance': mycroft.dialog.get("reset to factory defaults")}))
time.sleep(5)
self.ws.emit(Message("enclosure.mouth.reset"))
subprocess.call('systemctl reboot -i', shell=True)
@ -147,9 +148,13 @@ class EnclosureReader(Thread):
# This is handled by the wifi client
self.ws.emit(Message("mycroft.enable.ssh"))
self.ws.emit(Message("speak", {
'utterance': "SSH will be enabled on next boot"}))
time.sleep(5)
subprocess.call('systemctl reboot -i', shell=True)
'utterance': mycroft.dialog.get("ssh enabled")}))
if "unit.disable-ssh" in data:
# This is handled by the wifi client
self.ws.emit(Message("mycroft.disable.ssh"))
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("ssh disabled")}))
def stop(self):
self.alive = False

View File

@ -110,7 +110,7 @@ class DialogLoader(object):
return self.__renderer
def get(phrase, lang, context=None):
def get(phrase, lang=None, context=None):
"""
Looks up a resource file for the given phrase. If no file
is found, the requested phrase is returned as the string.
@ -125,6 +125,10 @@ def get(phrase, lang, context=None):
str: a randomized and/or translated version of the phrase
"""
if not lang:
from mycroft.configuration import ConfigurationManager
lang = ConfigurationManager.instance().get("lang")
filename = "text/"+lang.lower()+"/"+phrase+".dialog"
template = resolve_resource_file(filename)
if not template:

View File

@ -0,0 +1 @@
I have been reset to factory defaults.

View File

@ -0,0 +1 @@
SSH logins will be disabled next time I restart

View File

@ -0,0 +1 @@
SSH will be enabled next time I restart