Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont assume the BROWSER env var always exists #63

Closed
kovidgoyal opened this issue Jun 12, 2018 · 3 comments
Closed

Dont assume the BROWSER env var always exists #63

kovidgoyal opened this issue Jun 12, 2018 · 3 comments

Comments

@kovidgoyal
Copy link

diff --git a/urlscan/urlchoose.py b/urlscan/urlchoose.py
index 531321f..34f26c7 100644
--- a/urlscan/urlchoose.py
+++ b/urlscan/urlchoose.py
@@ -103,7 +103,7 @@ class URLChooser:
         for k in keys:
             if (k == 'enter' or k == ' ') and self.urls:
                 load_text = "Loading URL..." if not self.run else "Executing: {}".format(self.run)
-                if os.environ['BROWSER'] not in ['elinks', 'links', 'w3m', 'lynx']:
+                if os.environ.get('BROWSER') not in ['elinks', 'links', 'w3m', 'lynx']:
                     self._footer_start_thread(load_text, 5)
         # filter backspace out before the widget, it has a weird interaction
         return [i for i in keys if i != 'backspace']
@marcelpaulo
Copy link

marcelpaulo commented Jul 18, 2018

My very first run of urlscan, wanting to stop using urlview because of its problems, and got this:

Traceback (most recent call last):
  File "/home/paulo/.local/bin/urlscan", line 4, in <module>
    __import__('pkg_resources').run_script('urlscan==0.8.7', 'urlscan')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1438, in run_script
    exec(code, namespace, namespace)
  File "/home/paulo/.local/lib/python3.6/site-packages/urlscan-0.8.7-py3.6.egg/EGG-INFO/scripts/urlscan", line 176, in <module>
    ui.main()
  File "/home/paulo/.local/lib/python3.6/site-packages/urlscan-0.8.7-py3.6.egg/urlscan/urlchoose.py", line 97, in main
    loop.run()
  File "/home/paulo/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/home/paulo/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 379, in _run
    return self._run_screen_event_loop()
  File "/home/paulo/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 444, in _run_screen_event_loop
    keys = self.input_filter(keys, raw)
  File "/home/paulo/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 547, in input_filter
    return self._input_filter(keys, raw)
  File "/home/paulo/.local/lib/python3.6/site-packages/urlscan-0.8.7-py3.6.egg/urlscan/urlchoose.py", line 106, in handle_keys
    if os.environ['BROWSER'] not in ['elinks', 'links', 'w3m', 'lynx']:
  File "/usr/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'BROWSER'

@kovidgoyal has sent a patch here, and @mgedmin submitted #60. Why none have got into master yet ?

Once BROWSER is set in /etc/environment, urlscan works really great. It doesn't have a really pesky urlview bug, which made me abandon it: if the browser was closed and urlview opened it, urlview kills the browser when quitting mutt; in the same situation, it also kills the browser when closing it with ctrl-c. urlscan doesn't kill the browser in none of these situations.

@firecat53
Copy link
Owner

Sorry guys...I just haven't had time...ya know...summer, kids, other projects. I'll get to it, I promise!

@marcelpaulo
Copy link

@firecat53, enjoy the summer, and forget about urlscan ! It's no big deal to add BROWSER to /etc/environment, actually it may be useful, I already have EDITOR there. urlscan is working flawlessly with BROWSER set !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants