From d7bb75d065318aa41e6862526d5cd4b851646eaa Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Mon, 4 Sep 2017 23:07:23 -0400 Subject: [PATCH] Adding helper script --- scripts/inspect_webbrowser.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/inspect_webbrowser.py diff --git a/scripts/inspect_webbrowser.py b/scripts/inspect_webbrowser.py new file mode 100755 index 0000000..e9b7493 --- /dev/null +++ b/scripts/inspect_webbrowser.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +""" +Utility script used to examine the python webbrowser module with different OSs. +""" + +import os + +os.environ['BROWSER'] = 'firefox' + +# If we want to override the $BROWSER variable that the python webbrowser +# references, it needs to be done before the webbrowser module is imported +# for the first time. +RTV_BROWSER, BROWSER = os.environ.get('RTV_BROWSER'), os.environ.get('BROWSER') +if RTV_BROWSER: + os.environ['BROWSER'] = RTV_BROWSER + +print('RTV_BROWSER=%s' % BROWSER) +print('BROWSER=%s' % BROWSER) + +import webbrowser + +print('webbrowser._browsers:') +for key, val in webbrowser._browsers.items(): + print(' %s: %s' % (key, val)) + +print('webbrowser._tryorder:') +for name in webbrowser._tryorder: + print(' %s' % name) + +webbrowser.open_new_tab('https://www.python.org')