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
							parent
							
								
									317b497d5f
								
							
						
					
					
						commit
						1b200089c0
					
				| 
						 | 
					@ -24,6 +24,7 @@ from threading import Thread, Timer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import serial
 | 
					import serial
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import mycroft.dialog
 | 
				
			||||||
from mycroft.client.enclosure.arduino import EnclosureArduino
 | 
					from mycroft.client.enclosure.arduino import EnclosureArduino
 | 
				
			||||||
from mycroft.client.enclosure.eyes import EnclosureEyes
 | 
					from mycroft.client.enclosure.eyes import EnclosureEyes
 | 
				
			||||||
from mycroft.client.enclosure.mouth import EnclosureMouth
 | 
					from mycroft.client.enclosure.mouth import EnclosureMouth
 | 
				
			||||||
| 
						 | 
					@ -80,7 +81,7 @@ class EnclosureReader(Thread):
 | 
				
			||||||
            self.ws.emit(Message("enclosure.start"))
 | 
					            self.ws.emit(Message("enclosure.start"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "mycroft.stop" in data:
 | 
					        if "mycroft.stop" in data:
 | 
				
			||||||
            create_signal('buttonPress')  # FIXME - Must use WS instead
 | 
					            create_signal('buttonPress')
 | 
				
			||||||
            self.ws.emit(Message("mycroft.stop"))
 | 
					            self.ws.emit(Message("mycroft.stop"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "volume.up" in data:
 | 
					        if "volume.up" in data:
 | 
				
			||||||
| 
						 | 
					@ -138,7 +139,7 @@ class EnclosureReader(Thread):
 | 
				
			||||||
                shell=True)
 | 
					                shell=True)
 | 
				
			||||||
            self.ws.emit(Message("mycroft.wifi.reset"))
 | 
					            self.ws.emit(Message("mycroft.wifi.reset"))
 | 
				
			||||||
            self.ws.emit(Message("speak", {
 | 
					            self.ws.emit(Message("speak", {
 | 
				
			||||||
                'utterance': "This unit has been reset"}))
 | 
					                'utterance': mycroft.dialog.get("reset to factory defaults")}))
 | 
				
			||||||
            time.sleep(5)
 | 
					            time.sleep(5)
 | 
				
			||||||
            self.ws.emit(Message("enclosure.mouth.reset"))
 | 
					            self.ws.emit(Message("enclosure.mouth.reset"))
 | 
				
			||||||
            subprocess.call('systemctl reboot -i', shell=True)
 | 
					            subprocess.call('systemctl reboot -i', shell=True)
 | 
				
			||||||
| 
						 | 
					@ -147,9 +148,13 @@ class EnclosureReader(Thread):
 | 
				
			||||||
            # This is handled by the wifi client
 | 
					            # This is handled by the wifi client
 | 
				
			||||||
            self.ws.emit(Message("mycroft.enable.ssh"))
 | 
					            self.ws.emit(Message("mycroft.enable.ssh"))
 | 
				
			||||||
            self.ws.emit(Message("speak", {
 | 
					            self.ws.emit(Message("speak", {
 | 
				
			||||||
                'utterance': "SSH will be enabled on next boot"}))
 | 
					                'utterance': mycroft.dialog.get("ssh enabled")}))
 | 
				
			||||||
            time.sleep(5)
 | 
					
 | 
				
			||||||
            subprocess.call('systemctl reboot -i', shell=True)
 | 
					        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):
 | 
					    def stop(self):
 | 
				
			||||||
        self.alive = False
 | 
					        self.alive = False
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ class DialogLoader(object):
 | 
				
			||||||
        return self.__renderer
 | 
					        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
 | 
					    Looks up a resource file for the given phrase.  If no file
 | 
				
			||||||
    is found, the requested phrase is returned as the string.
 | 
					    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
 | 
					        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"
 | 
					    filename = "text/"+lang.lower()+"/"+phrase+".dialog"
 | 
				
			||||||
    template = resolve_resource_file(filename)
 | 
					    template = resolve_resource_file(filename)
 | 
				
			||||||
    if not template:
 | 
					    if not template:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					I have been reset to factory defaults.
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					SSH logins will be disabled next time I restart
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					SSH will be enabled next time I restart
 | 
				
			||||||
		Loading…
	
		Reference in New Issue