From: Fredrik Tolf Date: Wed, 2 Jun 2021 00:45:40 +0000 (+0200) Subject: auth: Add "support" for displaying images. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=216561679af237371dc62bd7a1a07aed9dad3d83;p=fulbank.git auth: Add "support" for displaying images. It just calls sxiv right now, but what's the alternative? SIXEL? --- diff --git a/fulbank/auth.py b/fulbank/auth.py index 013b873..deb065c 100644 --- a/fulbank/auth.py +++ b/fulbank/auth.py @@ -1,4 +1,4 @@ -import sys, os, io, termios +import sys, os, io, termios, tempfile, subprocess class autherror(Exception): pass @@ -14,6 +14,8 @@ class conv(object): pass def prompt(self, prompt, echo, default=None): return default + def image(self, image): + pass class termconv(conv): def __init__(self, ifp, ofp): @@ -49,6 +51,14 @@ class termconv(conv): return ret[:-1] finally: termios.tcsetattr(self.ifp.fileno(), termios.TCSANOW, bka) + def image(self, image): + fd, fn = tempfile.mkstemp() + try: + with os.fdopen(fd, "wb") as fp: + image.save(fp, "PNG") + subprocess.call(["sxiv", fn]) + finally: + os.unlink(fn) class ctermconv(termconv): def __init__(self, fp):