From 05adb44cdec74256fa44ce3a3df61c6525ce7fac Mon Sep 17 00:00:00 2001 From: William Zhang Date: Sat, 18 Feb 2017 20:57:08 -0500 Subject: [PATCH 1/2] Remove removal of DISPLAY environment variable The issue has to do with the two lines: ` if "DISPLAY" in os.environ: del os.environ["DISPLAY"]` This seems to remove the DISPLAY environment variable unnecessarily, as on line 50 of xvfbwrapper.py, self.orig_display is set to the value of DISPLAY. self.orig_display is checked on line 83, which is where the error occurs. Because of xvfb.py removing the environment variable and self.orig_display being set to the original value, on line 84 when it tries to remove DISPLAY, it has already been removed by xvfb.py, so it throws a KeyError. --- dryscrape/xvfb.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dryscrape/xvfb.py b/dryscrape/xvfb.py index 6b27ca1..af4f9a3 100644 --- a/dryscrape/xvfb.py +++ b/dryscrape/xvfb.py @@ -3,15 +3,15 @@ _xvfb = None + def start_xvfb(): - from xvfbwrapper import Xvfb - global _xvfb - if "DISPLAY" in os.environ: - del os.environ["DISPLAY"] - _xvfb = Xvfb() - _xvfb.start() - atexit.register(_xvfb.stop) + from xvfbwrapper import Xvfb + global _xvfb + _xvfb = Xvfb() + _xvfb.start() + atexit.register(_xvfb.stop) + def stop_xvfb(): - global _xvfb - _xvfb.stop() + global _xvfb + _xvfb.stop() From 63540eeaca083cd4b44e22c735679dfb7c24237b Mon Sep 17 00:00:00 2001 From: William Zhang Date: Sat, 18 Feb 2017 21:12:25 -0500 Subject: [PATCH 2/2] Two space indent size to be consistent --- dryscrape/xvfb.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dryscrape/xvfb.py b/dryscrape/xvfb.py index af4f9a3..00f7b87 100644 --- a/dryscrape/xvfb.py +++ b/dryscrape/xvfb.py @@ -5,13 +5,13 @@ def start_xvfb(): - from xvfbwrapper import Xvfb - global _xvfb - _xvfb = Xvfb() - _xvfb.start() - atexit.register(_xvfb.stop) + from xvfbwrapper import Xvfb + global _xvfb + _xvfb = Xvfb() + _xvfb.start() + atexit.register(_xvfb.stop) def stop_xvfb(): - global _xvfb - _xvfb.stop() + global _xvfb + _xvfb.stop()