Skip to content

Commit 2604361

Browse files
committed
Add debug attribute and conditionals at init from Browser
1 parent dd51eb9 commit 2604361

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

devtools/browser.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,30 @@
77

88

99
class Browser:
10-
def __init__(self, path=None):
10+
def __init__(self, debug=None, path=None):
1111
self.pipes = Pipe()
1212

13+
if not debug: # false o None
14+
stderr=subprocess.DEVNULL
15+
elif debug is True:
16+
stderr=None
17+
else:
18+
stderr=debug
19+
1320
if not path:
1421
if platform.system() == "Windows":
1522
path = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
1623
elif platform.system() == "Linux":
1724
path = "/usr/bin/google-chrome-stable"
1825
else:
1926
raise ValueError("You must set path to a chrome-like browser")
27+
2028
new_env = os.environ.copy()
2129
new_env["CHROMIUM_PATH"] = path
2230
win_only = {}
2331
if platform.system() == "Windows":
2432
win_only = {"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP}
33+
2534
proc = subprocess.Popen(
2635
[
2736
sys.executable,
@@ -32,7 +41,7 @@ def __init__(self, path=None):
3241
close_fds=True,
3342
stdin=self.pipe.read_to_chromium,
3443
stdout=self.pipe.write_from_chromium,
35-
stderr=None,
44+
stderr=stderr,
3645
env=new_env,
3746
**win_only,
3847
)

0 commit comments

Comments
 (0)