fixed preview script
This commit is contained in:
parent
bf90fc3031
commit
b502912d7f
@ -4,31 +4,30 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
import random
|
|
||||||
from http.server import HTTPServer
|
from http.server import HTTPServer
|
||||||
import shutil
|
import shutil
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
sys.path.insert(0,
|
sys.path.insert(0,
|
||||||
os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
'../sdcard/rootfs/root/pwnagotchi/scripts/'))
|
'../sdcard/rootfs/root/pwnagotchi/scripts/'))
|
||||||
|
|
||||||
from pwnagotchi.ui.view import View
|
|
||||||
from pwnagotchi.ui.display import Display, VideoHandler
|
from pwnagotchi.ui.display import Display, VideoHandler
|
||||||
import core
|
import core
|
||||||
|
|
||||||
|
|
||||||
class CustomDisplay(Display):
|
class CustomDisplay(Display):
|
||||||
|
|
||||||
def _http_serve(self):
|
def _http_serve(self):
|
||||||
if self._video_address is not None:
|
if self._video_address is not None:
|
||||||
self._httpd = HTTPServer((self._video_address, self._video_port),
|
self._httpd = HTTPServer((self._video_address, self._video_port),
|
||||||
CustomVideoHandler)
|
CustomVideoHandler)
|
||||||
core.log("ui available at http://%s:%d/" % (self._video_address,
|
core.log("ui available at http://%s:%d/" % (self._video_address,
|
||||||
self._video_port))
|
self._video_port))
|
||||||
self._httpd.serve_forever()
|
self._httpd.serve_forever()
|
||||||
else:
|
else:
|
||||||
core.log("could not get ip of usb0, video server not starting")
|
core.log("could not get ip of usb0, video server not starting")
|
||||||
|
|
||||||
|
|
||||||
def _on_view_rendered(self, img):
|
def _on_view_rendered(self, img):
|
||||||
CustomVideoHandler.render(img)
|
CustomVideoHandler.render(img)
|
||||||
|
|
||||||
@ -44,9 +43,9 @@ class CustomVideoHandler(VideoHandler):
|
|||||||
def render(img):
|
def render(img):
|
||||||
with CustomVideoHandler._lock:
|
with CustomVideoHandler._lock:
|
||||||
try:
|
try:
|
||||||
img.save("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), format='PNG')
|
img.save("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), format='PNG')
|
||||||
except BaseException:
|
except BaseException:
|
||||||
core.log("could not write preview")
|
core.log("could not write preview")
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
if self.path == '/':
|
if self.path == '/':
|
||||||
@ -107,12 +106,11 @@ def main():
|
|||||||
type: {display}
|
type: {display}
|
||||||
video:
|
video:
|
||||||
enabled: true
|
enabled: true
|
||||||
address: "127.0.0.1"
|
address: "0.0.0.0"
|
||||||
port: {port}
|
port: {port}
|
||||||
'''.format(display=args.display,
|
'''.format(display=args.display,
|
||||||
port=args.port,
|
port=args.port,
|
||||||
lang=args.lang),
|
lang=args.lang))
|
||||||
Loader=yaml.FullLoader)
|
|
||||||
|
|
||||||
DISPLAY = CustomDisplay(config=CONFIG, state={'name': '%s>' % 'preview'})
|
DISPLAY = CustomDisplay(config=CONFIG, state={'name': '%s>' % 'preview'})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user