balta2ar / brotab

Control your browser's tabs from the command line
MIT License
389 stars 27 forks source link

Focused option doesnt seem to work on Firefox #35

Closed brpaz closed 2 years ago

brpaz commented 4 years ago

First of all, congrats for this amazing tool.

It seems that Focused is not working on Firefox. Also sometimes the "activate" stops working and give some errors like this:

() | Incoming event ItemEnterEvent
Traceback (most recent call last):
  File "/usr/local/bin/brotab", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/brotab/main.py", line 670, in main
    exit(run_commands(sys.argv[1:]))
  File "/usr/local/lib/python3.8/site-packages/brotab/main.py", line 663, in run_commands
    result = args.func(args)
  File "/usr/local/lib/python3.8/site-packages/brotab/main.py", line 168, in activate_tab
    api.activate_tab(args.tab_id, args.focused)
  File "/usr/local/lib/python3.8/site-packages/brotab/api.py", line 295, in activate_tab
    api.activate_tab(args, focused)
  File "/usr/local/lib/python3.8/site-packages/brotab/api.py", line 112, in activate_tab
    self._get('/activate_tab/%s%s' % (tab_id, '?focused=1' if focused else ''))
  File "/usr/local/lib/python3.8/site-packages/brotab/api.py", line 249, in _get
    with urlopen(request, timeout=HTTP_TIMEOUT) as response:
  File "/usr/lib64/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib64/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib64/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR
balta2ar commented 4 years ago

Can you consistently reproduce this problem? When that happens next time, could you send me /tmp/brotab.log and /tmp/brotab_mediator.log. It's important to know what were the previous commands, since it's likely that something before that broke the mediator, like an unhandled timeout.

yasenn commented 3 years ago

@balta2ar tx for your tips and thanks a lot for brotab - it helps me every day!

TL;DR:

I had same error, and in my case it was due to broken bt client and fixed by killing it

Env

Linux Ubuntu 18 Two browsers (Chrome and Firefox) both with active installed brotab extensions

Steps to reproduce

Try to get active tab:

$bt active
Traceback (most recent call last):
  File "/usr/local/bin/bt", line 12, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/brotab-1.3.0-py3.6.egg/brotab/main.py", line 670, in main
  File "/usr/local/lib/python3.6/dist-packages/brotab-1.3.0-py3.6.egg/brotab/main.py", line 663, in run_commands
  File "/usr/local/lib/python3.6/dist-packages/brotab-1.3.0-py3.6.egg/brotab/main.py", line 175, in show_active_tabs
  File "/usr/local/lib/python3.6/dist-packages/brotab-1.3.0-py3.6.egg/brotab/api.py", line 115, in get_active_tabs
  File "/usr/local/lib/python3.6/dist-packages/brotab-1.3.0-py3.6.egg/brotab/api.py", line 249, in _get
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR`

get_browser drops an error:

tail /tmp/brotab.log
2020-09-24 09:31:59,914 INFO       Showing active tabs: Namespace(func=<function show_active_tabs at 0x7fd5db717950>, target_hosts=None)
2020-09-24 09:31:59,916 INFO       GET http://localhost:4625/get_pid
2020-09-24 09:31:59,929 INFO       GET http://localhost:4625/get_browser
2020-09-24 09:31:59,938 INFO       _get_browser failed: HTTP Error 500: INTERNAL SERVER ERROR

Solution

Show me clients

bt clients
a.      localhost:4625  4588    <ERROR>
b.      localhost:4626  2820637 firefox

Kill frozen client:

bt clients | awk '/ERROR/{print $3}' | xargs kill -9

And then all works

brpaz commented 2 years ago

Yep. I totally forgot this issue and got it working somehow. Don´t remember having any issues like this recently. probably it was what @yasenn said.

I will close this.