From 4f694ddb83244f094a6a0c5a0aa40c3b329ea50d Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Mon, 7 Oct 2019 19:42:29 +0200 Subject: [PATCH] new: added clean shutdown button to the web ui (closes #161) --- pwnagotchi/__init__.py | 14 ++++++++++++++ pwnagotchi/ui/display.py | 27 ++++++++++++++++++++++++--- pwnagotchi/ui/view.py | 16 +++++++++++++++- pwnagotchi/voice.py | 5 +++++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py index ff43494..c343bb3 100644 --- a/pwnagotchi/__init__.py +++ b/pwnagotchi/__init__.py @@ -1,4 +1,8 @@ import subprocess +import os +import logging +import time +import pwnagotchi.ui.view as view version = '1.0.0a' @@ -46,3 +50,13 @@ def temperature(celsius=True): temp = int(fp.read().strip()) c = int(temp / 1000) return c if celsius else ((c * (9 / 5)) + 32) + + +def shutdown(): + logging.warning("shutting down ...") + if view.ROOT: + view.ROOT.on_shutdown() + # give it some time to refresh the ui + time.sleep(5) + os.system("sync") + os.system("halt") diff --git a/pwnagotchi/ui/display.py b/pwnagotchi/ui/display.py index 76e9a24..ffefa18 100644 --- a/pwnagotchi/ui/display.py +++ b/pwnagotchi/ui/display.py @@ -15,11 +15,29 @@ class VideoHandler(BaseHTTPRequestHandler): _lock = Lock() _index = """ - %s + %s + - - +
+ +
+
+
+ +
+
+