Add Lenna to the test dir so the gr.py script becomes self-sufficient

This commit is contained in:
Kovid Goyal 2017-10-17 10:15:38 +05:30
parent 02dc637ed0
commit 192b16e9ff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 18 additions and 7 deletions

BIN
kitty_tests/Lenna.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

View File

@ -3,7 +3,6 @@
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import os
import subprocess
import sys
import zlib
from base64 import standard_b64encode
@ -40,6 +39,15 @@ def display(data, width, height, x, y, z, ncols=0, nrows=0):
cmd.clear()
def display_png_file(path):
cmd = {'a': 'T', 't': 'f', 'f': '100'}
path = os.path.abspath(path)
if not isinstance(path, bytes):
path = path.encode(sys.getfilesystemencoding() or 'utf-8')
data = standard_b64encode(path)
write_gr_cmd(cmd, data)
def main():
clear_screen()
display(b'\xdd\xdd\xdd\xff', 1, 1, 0, 0, -10, 40, 20)
@ -48,14 +56,17 @@ def main():
move_cursor(5, 8)
print('kitty is \033[3m\033[32mawesome\033[m!')
move_cursor(0, 21)
if os.path.exists('/t/Lenna.png'):
print('Lenna...')
subprocess.check_call('python3 kitty/icat.py /t/Lenna.png'.split())
print('Lenna...')
display_png_file('kitty_tests/Lenna.png')
try:
raw_input()
except NameError:
input()
try:
raw_input()
except NameError:
input()
except (EOFError, KeyboardInterrupt):
pass
if __name__ == '__main__':
os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
main()