Re-implemented fix for Firefox error messages.

This commit is contained in:
Michael Lazar
2015-03-05 22:56:09 -08:00
parent 8201460e9c
commit db179bd42b

View File

@@ -1,4 +1,5 @@
import os import os
import sys
import curses import curses
import time import time
import threading import threading
@@ -65,17 +66,16 @@ def load_config():
return defaults return defaults
def patch_popen(): def hide_stderr():
""" """
Patch subprocess.Popen default behavior to redirect stdout + stderr to null. Redirect all stderr output to null. This is a hack to stop the webbrowser
This is a hack to stop the webbrowser from spewing errors in firefox. from spewing errors in firefox.
""" """
# http://stackoverflow.com/a/13359757/2526287 # http://www.thecodingforums.com/threads/how-to-change-redirect-stderr.355342/#post-1868822
stdout = open(os.devnull, 'w') sys.stderr.flush()
func = partial(subprocess.Popen.__init__, err = open(os.devnull, 'ab+', 0)
stdout=stdout, stderr=stdout, close_fds=True) os.dup2(err.fileno(), sys.stderr.fileno())
subprocess.Popen.__init__ = create_bound_method(func, subprocess.Popen)
def text_input(window): def text_input(window):
""" """
@@ -204,12 +204,12 @@ class LoadScreen(object):
def curses_session(): def curses_session():
try: try:
# Curses must wait for some time after the Escape key is pressed to see # Curses must wait for some time after the Escape key is pressed to
# check if it is the beginning of an escape sequence indicating a # check if it is the beginning of an escape sequence indicating a
# special key. The default wait time is 1 second, which means that # special key. The default wait time is 1 second, which means that
# getch() will not return the escape key (27), until a full second # getch() will not return the escape key (27) until a full second
# after it has been pressed. Turn this down to 25 ms, which is close to # after it has been pressed.
# what VIM uses. # Turn this down to 25 ms, which is close to what VIM uses.
# http://stackoverflow.com/questions/27372068 # http://stackoverflow.com/questions/27372068
os.environ['ESCDELAY'] = '25' os.environ['ESCDELAY'] = '25'
@@ -234,14 +234,13 @@ def curses_session():
curses.start_color() curses.start_color()
except: except:
pass pass
else:
Color.init() Color.init()
# Hide blinking cursor # Hide blinking cursor
curses.curs_set(0) curses.curs_set(0)
# Breaks python3 hide_stderr()
# patch_popen()
yield stdscr yield stdscr