diff options
author | nfnty <git@nfnty.se> | 2017-01-20 16:09:19 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-21 23:09:24 +0100 |
commit | 1687e0f41f172cef6923f75f4c6f1038f19671dc (patch) | |
tree | 6b9fcb40ed3637cf13a8a9be9975504aadb5e90b /ranger/gui/ui.py | |
parent | e53369588ee44a9fc4ec75228dc041448aa778d4 (diff) | |
download | ranger-1687e0f41f172cef6923f75f4c6f1038f19671dc.tar.gz |
linting: pylint: Enable `broad-except`, Improve logging
Handle exceptions explicitly to prevent unexpected errors from causing problems. Improve exception and notification logging.
Diffstat (limited to 'ranger/gui/ui.py')
-rw-r--r-- | ranger/gui/ui.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 6c84580b..20e01536 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -91,12 +91,12 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method curses.halfdelay(20) try: curses.curs_set(int(bool(self.settings.show_cursor))) - except Exception: + except curses.error: pass curses.start_color() try: curses.use_default_colors() - except Exception: + except curses.error: pass self.settings.signal_bind('setopt.mouse_enabled', _setup_mouse) @@ -130,7 +130,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method curses.echo() try: curses.curs_set(1) - except Exception: + except curses.error: pass if self.settings.mouse_enabled: _setup_mouse(dict(value=False)) @@ -346,14 +346,16 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method try: fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \ decode('utf-8', 'replace') - sys.stdout.write("%sranger:%s%s" % ( + fmt_tup = ( curses.tigetstr('tsl').decode('latin-1'), fixed_cwd, curses.tigetstr('fsl').decode('latin-1'), - )) - sys.stdout.flush() - except Exception: + ) + except UnicodeError: pass + else: + sys.stdout.write("%sranger:%s%s" % fmt_tup) + sys.stdout.flush() self.win.refresh() |