Dolda2000 GitWeb
/
fulbank.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
auth: Add "support" for displaying images.
[fulbank.git]
/
fulbank
/
auth.py
diff --git
a/fulbank/auth.py
b/fulbank/auth.py
index
1a9f13d
..
deb065c
100644
(file)
--- a/
fulbank/auth.py
+++ b/
fulbank/auth.py
@@
-1,4
+1,7
@@
-import sys, os, io, termios
+import sys, os, io, termios, tempfile, subprocess
+
+class autherror(Exception):
+ pass
class conv(object):
msg_notice = 0
class conv(object):
msg_notice = 0
@@
-11,6
+14,8
@@
class conv(object):
pass
def prompt(self, prompt, echo, default=None):
return default
pass
def prompt(self, prompt, echo, default=None):
return default
+ def image(self, image):
+ pass
class termconv(conv):
def __init__(self, ifp, ofp):
class termconv(conv):
def __init__(self, ifp, ofp):
@@
-46,10
+51,18
@@
class termconv(conv):
return ret[:-1]
finally:
termios.tcsetattr(self.ifp.fileno(), termios.TCSANOW, bka)
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(conv):
+class ctermconv(
term
conv):
def __init__(self, fp):
def __init__(self, fp):
- super().__init__(fp)
+ super().__init__(fp
, fp
)
self.cfp = fp
def close(self):
self.cfp = fp
def close(self):
@@
-64,7
+77,7
@@
null = conv()
stdioconv = termconv(sys.stdin, sys.stdout)
def ttyconv():
stdioconv = termconv(sys.stdin, sys.stdout)
def ttyconv():
- return ctermconv(io.TextIOWrapper(io.FileIO(os.open("/dev/tty", os.O_RDWR | os.O_NCTTY), "r+")))
+ return ctermconv(io.TextIOWrapper(io.FileIO(os.open("/dev/tty", os.O_RDWR | os.O_N
O
CTTY), "r+")))
def default():
return null
def default():
return null