aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2017-09-30 18:44:45 +0000
committerMike Crute <mike@crute.us>2017-09-30 23:09:18 +0000
commitfdfb18a78e0014d362a2e0654eabf706094e4f09 (patch)
tree40069ec26e0095a1238777119cea2e4c00359cc4
parentc09e16c4f375a9d9b29b7c34e9d62f9cab1e8c69 (diff)
downloadpydora-fdfb18a78e0014d362a2e0654eabf706094e4f09.tar.bz2
pydora-fdfb18a78e0014d362a2e0654eabf706094e4f09.tar.xz
pydora-fdfb18a78e0014d362a2e0654eabf706094e4f09.zip
Check if termios is present or ignore
termios is POSIX specific which doesn't work for Windows users using the CLI. Check for the presence of termios and disable the set_echo function if it's not present. The only reason echo is disabled during polling is to prevent control characters entered by a user from displaying in the playlist so it's more cosmetic than anything.
-rw-r--r--pydora/utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pydora/utils.py b/pydora/utils.py
index 47422d6..3c48117 100644
--- a/pydora/utils.py
+++ b/pydora/utils.py
@@ -2,10 +2,15 @@ from __future__ import print_function
2 2
3import os 3import os
4import sys 4import sys
5import termios
6import getpass 5import getpass
7import subprocess 6import subprocess
8 7
8try:
9 import termios
10except ImportError:
11 # Windows does not have a termios module
12 termios = None
13
9 14
10def input(prompt): 15def input(prompt):
11 try: 16 try:
@@ -39,6 +44,9 @@ class Screen(object):
39 44
40 @staticmethod 45 @staticmethod
41 def set_echo(enabled): 46 def set_echo(enabled):
47 if not termios:
48 return
49
42 handle = sys.stdin.fileno() 50 handle = sys.stdin.fileno()
43 if not os.isatty(handle): 51 if not os.isatty(handle):
44 return 52 return