modified: mycroft/client/enclosure/__init__.py

modified:   mycroft/client/wifisetup/main.py
pull/748/head
kfezer@gmail.com 2017-05-02 16:40:41 -07:00 committed by Art McGee
parent 579ddef45a
commit b5ec28ed27
2 changed files with 14 additions and 3 deletions

View File

@ -131,8 +131,6 @@ class EnclosureReader(Thread):
self.ws.emit(Message("mycroft.wifi.start"))
if "unit.factory-reset" in data:
self.ws.emit(
Message("enclosure.eyes.spin"))
subprocess.call(
'rm ~/.mycroft/identity/identity2.json',
shell=True)
@ -144,9 +142,12 @@ class EnclosureReader(Thread):
subprocess.call('systemctl reboot -i', shell=True)
if "unit.enable-ssh" in data:
subprocess.call('sudo touch /boot/ssh', shell=True)
#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(4)
subprocess.call('systemctl reboot -i', shell=True)
def stop(self):
self.alive = False

View File

@ -268,6 +268,9 @@ class WiFi:
# This event is similar to the above, but resets the wifi
self.ws.on('mycroft.wifi.reset', self.reset)
# an event to enable SSH
self.ws.on('enclosure.enable.ssh', self.ssh)
# These events are generated by Javascript in the captive
# portal.
self.ws.on('mycroft.wifi.stop', self.stop)
@ -560,6 +563,13 @@ class WiFi:
except Exception as e:
LOG.error("Error: {0}".format(e))
def ssh(self, event=None):
LOG.info("Enabling SSH")
try:
call('sudo touch /boot/ssh', shell=True)
except Exception as e:
LOG.error("Error: {0}".format(e))
def main():
wifi = WiFi()