dflock / ulauncher-window-switcher

Linux/X11 Window Switcher plugin for Ulauncher
GNU General Public License v3.0
14 stars 10 forks source link

Extension crashes immediately #5

Closed systemoperator closed 2 years ago

systemoperator commented 3 years ago

After installing, the extension crashes and the following message appears:

The extension exited instantly. Please check the logs.

I can't even change and save the keyword for triggering the extension.

OS: Ubuntu 16.04 python -V: Python 2.7.12 python3 -V: Python 3.5.2

Launching with ulauncher -v shows (when restarting ulauncher with this extension already installed) or when freshly installing the extension:

2021-06-24 14:42:12,064 | ERROR | ulauncher.api.server.ExtensionRunner: _run_process() | Extension "com.github.dflock.ulauncher-window-switcher" exited instantly with code 1
2021-06-24 14:42:12,066 | ERROR | ulauncher.api.server.ExtensionRunner: _run_process() | Extension "com.github.dflock.ulauncher-window-switcher" failed with an error: SyntaxError: invalid syntax

When installing and saving the settings:

Message: 'com.github.dflock.ulauncher-window-switcher' Error Name: UnhandledError Type: KeyError

Stacktrace:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 198, in on_scheme_callback
    resp = rt.dispatch(self, scheme_request.get_uri())
  File "/usr/lib/python3/dist-packages/ulauncher/utils/Router.py", line 49, in dispatch
    return callback(context, url_params)
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 444, in prefs_extension_update_prefs
    controller = ExtensionServer.get_instance().get_controller(ext_id)
  File "/usr/lib/python3/dist-packages/ulauncher/api/server/ExtensionServer.py", line 76, in get_controller
    return self.controllers[extension_id]
KeyError: 'com.github.dflock.ulauncher-window-switcher'

Where ulauncher -v showed:

2021-06-24 15:08:53,306 | ERROR | ulauncher.ui.windows.PreferencesUlauncherDialog: on_scheme_callback() | Unexpected API error. KeyError: 'com.github.dflock.ulauncher-window-switcher'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 198, in on_scheme_callback
    resp = rt.dispatch(self, scheme_request.get_uri())
  File "/usr/lib/python3/dist-packages/ulauncher/utils/Router.py", line 49, in dispatch
    return callback(context, url_params)
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 444, in prefs_extension_update_prefs
    controller = ExtensionServer.get_instance().get_controller(ext_id)
  File "/usr/lib/python3/dist-packages/ulauncher/api/server/ExtensionServer.py", line 76, in get_controller
    return self.controllers[extension_id]
KeyError: 'com.github.dflock.ulauncher-window-switcher'
2021-06-24 15:11:16,124 | INFO | ulauncher.ui.windows.PreferencesUlauncherDialog: prefs_extension_update_prefs() | Update extension preferences: {'pref.window_switcher_kw': 'win', 'id': 'com.github.dflock.ulauncher-window-switcher', 'callback': '__jp10'}

Sometimes, I could grab the following error:

Message: 'com.github.dflock.ulauncher-window-switcher' Error Name: UnhandledError Type: KeyError

Stacktrace:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 198, in on_scheme_callback
    resp = rt.dispatch(self, scheme_request.get_uri())
  File "/usr/lib/python3/dist-packages/ulauncher/utils/Router.py", line 49, in dispatch
    return callback(context, url_params)
  File "/usr/lib/python3/dist-packages/ulauncher/ui/windows/PreferencesUlauncherDialog.py", line 444, in prefs_extension_update_prefs
    controller = ExtensionServer.get_instance().get_controller(ext_id)
  File "/usr/lib/python3/dist-packages/ulauncher/api/server/ExtensionServer.py", line 76, in get_controller
    return self.controllers[extension_id]
KeyError: 'com.github.dflock.ulauncher-window-switcher'

Once, I only got:

Message: undefined Error Name: undefined Type: undefined

Stacktrace:

undefined
dflock commented 2 years ago

I'm not sure what would cause this.

I have just added checking for wmctrl at startup, so that might help?

systemoperator commented 2 years ago

@dflock I've tested the current version. When starting ulauncher, the following errors appear now:

main@w ~ % ulauncher

(ulauncher:18995): Gdk-CRITICAL **: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
  File "/home/w/.local/share/ulauncher/extensions/com.github.dflock.ulauncher-window-switcher/main.py", line 80
    description=f'Workspace {window["ws"]}: {ws_dict[window["ws"]]}, Window Id: {w_idx}',
                                                                                       ^
SyntaxError: invalid syntax
2021-11-26 16:35:27,539 | ERROR | ulauncher.api.server.ExtensionRunner: _run_process() | Extension "com.github.dflock.ulauncher-window-switcher" exited instantly with code 1
2021-11-26 16:35:27,540 | ERROR | ulauncher.api.server.ExtensionRunner: _run_process() | Extension "com.github.dflock.ulauncher-window-switcher" failed with an error: SyntaxError: invalid syntax

It seems to be a clash in the Python version, with unsupported features.

Replacing Line 80 with

description='Workspace ' + window["ws"] + ": " + ws_dict[window["ws"]] + ", Window Id: " + {w_idx},

and Line 81 with

on_enter=RunScriptAction("wmctrl -ia " + w_idx),

in /home/w/.local/share/ulauncher/extensions/com.github.dflock.ulauncher-window-switcher/main.py and running ulauncher again, it only shows:

main@w ~ % ulauncher

(ulauncher:26311): Gdk-CRITICAL **: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

When now trying to search for an open window, no windows appear in the list. The only entry is called "Loading...".

When quitting ulauncher from terminal, the following appears:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/api/client/Client.py", line 54, in on_message
    self.extension.trigger_event(event)
  File "/usr/lib/python3/dist-packages/ulauncher/api/client/Extension.py", line 52, in trigger_event
    action = listener.on_event(event, self)
  File "/home/w/.local/share/ulauncher/extensions/com.github.dflock.ulauncher-window-switcher/main.py", line 47, in on_event
    text=True,
  File "/usr/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ulauncher/api/client/Client.py", line 54, in on_message
    self.extension.trigger_event(event)
  File "/usr/lib/python3/dist-packages/ulauncher/api/client/Extension.py", line 52, in trigger_event
    action = listener.on_event(event, self)
  File "/home/w/.local/share/ulauncher/extensions/com.github.dflock.ulauncher-window-switcher/main.py", line 47, in on_event
    text=True,
  File "/usr/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'
com.github.dflock.ulauncher-window-switcher | 2021-11-26 16:43:54,553 | WARNING | ulauncher.api.client.Client: on_close() | Connection closed. Exiting

At least, the extension does not crash anymore.

dflock commented 2 years ago

Ugh, right - Python 3.5 doesn't have f strings! Sorry!

Fixed by https://github.com/dflock/ulauncher-window-switcher/commit/a5652bacdee7054930c5c4a791e5f9e78437da41

systemoperator commented 2 years ago

@dflock Which Python version do you use?

As it can be seen in the logs above, there is still is a problem with the call to subprocess.run():

        result = subprocess.run(
            ['wmctrl -l | awk \'{ if( $2 != "-1") { $3="";  print $0} }\''],
            capture_output=True,
            shell=True,
            text=True,
        ).stdout

Here capture_output=True, seems to be problematic:

TypeError: __init__() got an unexpected keyword argument 'capture_output'

The same applies to text=True.