FogBugz » FogBugzPy A Python wrapper for the FogBugz API Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9.1, 0.9.2, and 0.9.3

getch is needed for password input

Changeset 7b6c463f6526

Parent 0caf7da2558d

by Profile picture of User 10Tyler G. Hicks-Wright <tghw@fogcreek.com>

Changes to 2 files · Browse files at 7b6c463f6526 Showing diff from parent 0caf7da2558d Diff from another changeset...

Change 1 of 1 Show Entire File .hgignore Stacked
 
1
2
 
 
1
2
3
@@ -1,2 +1,3 @@
 syntax: glob  *.pyc +
Change 1 of 1 Show Entire File getch.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
@@ -1,0 +1,38 @@
+class _Getch: + """Gets a single character from standard input. Does not echo to the +screen.""" + def __init__(self): + try: + self.impl = _GetchWindows() + except ImportError: + self.impl = _GetchUnix() + + def __call__(self): return self.impl() + + +class _GetchUnix: + def __init__(self): + import tty, sys + + def __call__(self): + import sys, tty, termios + fd = sys.stdin.fileno() + old_settings = termios.tcgetattr(fd) + try: + tty.setraw(sys.stdin.fileno()) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) + return ch + + +class _GetchWindows: + def __init__(self): + import msvcrt + + def __call__(self): + import msvcrt + return msvcrt.getch() + + +getch = _Getch() \ No newline at end of file