summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Cope <olly@ollycope.com>2018-06-28 13:12:50 +0000
committerOlly Cope <olly@ollycope.com>2018-06-28 13:12:50 +0000
commit4f65f7d8e78fe9501f4e57a11b6e333511866cae (patch)
tree0caf295383ebd9d9f2f61b046262bcc8411b278d
parent89b9e04de17dc271bdde519b0c6c0b58b3221a25 (diff)
downloadyoyo-4f65f7d8e78fe9501f4e57a11b6e333511866cae.tar.gz
Fix issues with getch and line endings on Windows
-rwxr-xr-xyoyo/utils.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/yoyo/utils.py b/yoyo/utils.py
index a937b82..93d07d1 100755
--- a/yoyo/utils.py
+++ b/yoyo/utils.py
@@ -45,11 +45,11 @@ try:
return a
except ImportError:
- # some non Windows environments don't have termios (google cloud)
- # running yoyo through the python sdk should not require `getch`
try:
- from msvcrt import getch
- except:
+ from msvcrt import getwch as getch
+ except ImportError:
+ # some non Windows environments don't have termios (google cloud)
+ # running yoyo through the python sdk should not require `getch`
pass
@@ -62,7 +62,7 @@ def prompt(prompt, options):
sys.stdout.write("%s [%s]: " % (prompt, options))
sys.stdout.flush()
ch = getch()
- if ch == '\n':
+ if ch == os.linesep:
ch = ([o.lower() for o in options if 'A' <= o <= 'Z'] +
list(options.lower()))[0]
print(ch)