comparison mercurial/crecord.py @ 27528:7cc654610204 stable

crecord: use try/except for import of curses Not only does this improve fragility with 'if os.name == ...' it will help future patches enable the behavior to fallback to use plain record when curses is unavailable (e.g. python compiled without curses support).
author Sean Farley <sean@farley.io>
date Wed, 16 Dec 2015 10:33:19 -0800
parents 1aee2ab0f902
children 940cedaee988
comparison
equal deleted inserted replaced
27513:707cdf2c3700 27528:7cc654610204
28 28
29 # This is required for ncurses to display non-ASCII characters in default user 29 # This is required for ncurses to display non-ASCII characters in default user
30 # locale encoding correctly. --immerrr 30 # locale encoding correctly. --immerrr
31 locale.setlocale(locale.LC_ALL, '') 31 locale.setlocale(locale.LC_ALL, '')
32 32
33 # os.name is one of: 'posix', 'nt', 'dos', 'os2', 'mac', or 'ce' 33 try:
34 if os.name == 'posix':
35 import curses 34 import curses
36 import fcntl 35 import fcntl
37 import termios 36 import termios
38 else: 37 curses.error
38 fcntl.ioctl
39 termios.TIOCGWINSZ
40 except ImportError:
39 # I have no idea if wcurses works with crecord... 41 # I have no idea if wcurses works with crecord...
40 try: 42 try:
41 import wcurses as curses 43 import wcurses as curses
44 curses.error
42 except ImportError: 45 except ImportError:
43 # wcurses is not shipped on Windows by default 46 # wcurses is not shipped on Windows by default
44 pass 47 pass
45 48
46 try: 49 try: