OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 ''' |
| 3 PEXPECT LICENSE |
| 4 |
| 5 This license is approved by the OSI and FSF as GPL-compatible. |
| 6 http://opensource.org/licenses/isc-license.txt |
| 7 |
| 8 Copyright (c) 2012, Noah Spurrier <noah@noah.org> |
| 9 PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY |
| 10 PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE |
| 11 COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. |
| 12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 13 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 14 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 15 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 |
| 20 ''' |
| 21 try: |
| 22 # This allows coverage to measure code run in this process |
| 23 import coverage |
| 24 coverage.process_startup() |
| 25 except ImportError: |
| 26 pass |
| 27 |
| 28 from utils import no_coverage_env |
| 29 import pexpect |
| 30 import sys |
| 31 |
| 32 |
| 33 def main(): |
| 34 p = pexpect.spawn('{sys.executable} getch.py'.format(sys=sys), |
| 35 env=no_coverage_env()) |
| 36 |
| 37 # defaults matches api |
| 38 escape_character = chr(29) |
| 39 encoding = None |
| 40 |
| 41 if len(sys.argv) > 1 and '--no-escape' in sys.argv: |
| 42 escape_character = None |
| 43 |
| 44 if len(sys.argv) > 1 and '--utf8' in sys.argv: |
| 45 encoding = 'utf8' |
| 46 |
| 47 p.interact(escape_character=escape_character) |
| 48 |
| 49 print("Escaped interact") |
| 50 |
| 51 if __name__ == '__main__': |
| 52 main() |
OLD | NEW |