From 33f9917b903f0263ef81803f090b225ce3a57872 Mon Sep 17 00:00:00 2001 From: Panagiotis Vasilopoulos Date: Tue, 1 Oct 2019 16:41:43 +0000 Subject: [PATCH] Exception handlers in preview script --- scripts/preview.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/preview.py b/scripts/preview.py index 47afd7d3..16e4079e 100755 --- a/scripts/preview.py +++ b/scripts/preview.py @@ -43,7 +43,10 @@ class CustomVideoHandler(VideoHandler): @staticmethod def render(img): with CustomVideoHandler._lock: - img.save("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), format='PNG') + try: + img.save("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), format='PNG') + except BaseException: + core.log("could not write preview") def do_GET(self): if self.path == '/': @@ -67,7 +70,7 @@ class CustomVideoHandler(VideoHandler): with open("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), 'rb') as fp: shutil.copyfileobj(fp, self.wfile) except BaseException: - pass + core.log("could not open preview") else: self.send_response(404)