Added a patch to silence warnings from Firefox. #21.

This commit is contained in:
Michael Lazar
2015-03-04 22:36:17 -08:00
parent 0c18fd50e4
commit 46be3d6833

View File

@@ -4,6 +4,9 @@ import time
import threading import threading
from curses import textpad from curses import textpad
from contextlib import contextmanager from contextlib import contextmanager
import subprocess
from functools import partial
from types import MethodType
from .errors import EscapePressed from .errors import EscapePressed
@@ -43,6 +46,17 @@ class Color(object):
curses.init_pair(index, code[0], code[1]) curses.init_pair(index, code[0], code[1])
setattr(cls, attr, curses.color_pair(index)) setattr(cls, attr, curses.color_pair(index))
def patch_popen():
"""
Patch subprocess.Popen default behavior to redirect stdout + stderr to null.
This is a hack to stop the webbrowser from spewing errors in firefox.
"""
# http://stackoverflow.com/a/13359757/2526287
stdout = open(os.devnull, 'w')
func = partial(subprocess.Popen.__init__,
stdout=stdout, stderr=stdout, close_fds=True)
subprocess.Popen.__init__ = MethodType(func, None, subprocess.Popen)
def text_input(window): def text_input(window):
""" """
@@ -201,6 +215,8 @@ def curses_session():
# Hide blinking cursor # Hide blinking cursor
curses.curs_set(0) curses.curs_set(0)
patch_popen()
yield stdscr yield stdscr
finally: finally: