Exception handlers in preview script

This commit is contained in:
Panagiotis Vasilopoulos
2019-10-01 16:41:43 +00:00
parent 19c4b42072
commit 33f9917b90

View File

@ -43,7 +43,10 @@ class CustomVideoHandler(VideoHandler):
@staticmethod @staticmethod
def render(img): def render(img):
with CustomVideoHandler._lock: 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): def do_GET(self):
if self.path == '/': if self.path == '/':
@ -67,7 +70,7 @@ class CustomVideoHandler(VideoHandler):
with open("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), 'rb') as fp: with open("/tmp/pwnagotchi-{rand}.png".format(rand=id(CustomVideoHandler)), 'rb') as fp:
shutil.copyfileobj(fp, self.wfile) shutil.copyfileobj(fp, self.wfile)
except BaseException: except BaseException:
pass core.log("could not open preview")
else: else:
self.send_response(404) self.send_response(404)