Added support for shutdown

This commit is contained in:
Philip Trauner 2016-02-20 10:49:13 +01:00
parent 2bcbbaafd2
commit ed0d28ab1c
3 changed files with 5 additions and 2 deletions

View file

@ -27,7 +27,7 @@ class WallabyControl(Routing.ServerRoute):
for wallaby in handler.broadcast.channels[Handler.Channels.WALLABY]: for wallaby in handler.broadcast.channels[Handler.Channels.WALLABY]:
address_pair = "%s:%d" % (wallaby.address, wallaby.port) address_pair = "%s:%d" % (wallaby.address, wallaby.port)
if address_pair in data.keys(): if address_pair in data.keys():
if data[address_pair] in ("stop", "restart", "disconnect", "reboot"): if data[address_pair] in ("stop", "restart", "disconnect", "reboot", "shutdown"):
wallaby.send(data[address_pair], "wallaby_control") wallaby.send(data[address_pair], "wallaby_control")
elif type(data[address_pair]) is dict: elif type(data[address_pair]) is dict:
if "run" in data[address_pair]: if "run" in data[address_pair]:

View file

@ -104,7 +104,7 @@ class Fl0w:
def wallaby_control_submenu(self, wallaby): def wallaby_control_submenu(self, wallaby):
menu = Menu(subtitles=False) menu = Menu(subtitles=False)
for command in ("Stop", "Restart", "Reboot", "Disconnect"): for command in ("Stop", "Restart", "Shutdown", "Reboot", "Disconnect"):
menu.add(Entry(command, action=self.sock.send, kwargs={"data" : {wallaby : command.lower()}, "route" : "wallaby_control"})) menu.add(Entry(command, action=self.sock.send, kwargs={"data" : {wallaby : command.lower()}, "route" : "wallaby_control"}))
menu.invoke(self.window) menu.invoke(self.window)

View file

@ -26,6 +26,9 @@ class WallabyControl(Routing.ClientRoute):
os.system("reboot") os.system("reboot")
exit(0) exit(0)
def shutdown(self, handler):
os.system("shutdown -h 0")
def disconnect(self, handler): def disconnect(self, handler):
handler.sock.close() handler.sock.close()