Fix STDIN pipe detection logic
This commit is contained in:
parent
5e4ac9681b
commit
67772abe6d
7
main.py
7
main.py
@ -1,6 +1,5 @@
|
||||
from sys import argv, stdin
|
||||
from sys import exit as sysexit
|
||||
from select import select
|
||||
from hashlib import blake2b
|
||||
from io import BytesIO
|
||||
|
||||
@ -24,15 +23,11 @@ def get_input_stream():
|
||||
io = None
|
||||
if len(argv) == 2:
|
||||
io = BytesIO(argv[1].encode())
|
||||
elif stdin_has_data():
|
||||
elif not stdin.isatty():
|
||||
io = stdin.buffer
|
||||
return io
|
||||
|
||||
|
||||
def stdin_has_data():
|
||||
return bool(select([stdin], [], [], 0.0)[0])
|
||||
|
||||
|
||||
def print_usage_and_exit():
|
||||
print('Usage: identicon [TEXT]')
|
||||
print('Print OpenSSH style randomart identicon for arbitrary data.\n')
|
||||
|
Loading…
Reference in New Issue
Block a user