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

Handle empty command lines - catapult will break if a distribution has desktop files with empty command-lines #32

Merged

Conversation

UffeJakobsen
Copy link
Contributor

Handle empty command lines - catapult will break if a distribution has desktop files with empty command-lines

Example:

08:49:12 DEBUG: AppsPlugin: 569 items in index
08:49:12 DEBUG: AppsPlugin: 569 items in index
08:49:16 DEBUG: AppsPlugin: Updating index...
08:49:16 DEBUG: AppsPlugin: 569 items in index
08:49:17 DEBUG: SearchManager: Starting search for 'q'
08:49:17 DEBUG: AppsPlugin: Found qemu.desktop for 'q'
08:49:17 ERROR: Failed to get search results from apps
Traceback (most recent call last):
  File "/tmp/catapult-devel.git/catapult/search.py", line 59, in _get_results
    for i, result in enumerate(plugin.search(query)):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/catapult-devel.git/catapult/plugins/apps.py", line 99, in search
    description=self._get_description(app),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/catapult-devel.git/catapult/plugins/apps.py", line 61, in _get_description
    description = re.sub(r" %\w\b", "", description)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/re/__init__.py", line 186, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
08:49:17 DEBUG: SearchManager: builtins delivered in 0 ms
08:49:17 DEBUG: SearchManager: Found 0 results
08:49:17 DEBUG: SearchManager: Adjusted scores in 0 ms

…s desktop files with empty command-lines

Example:
```
08:49:12 DEBUG: AppsPlugin: 569 items in index
08:49:12 DEBUG: AppsPlugin: 569 items in index
08:49:16 DEBUG: AppsPlugin: Updating index...
08:49:16 DEBUG: AppsPlugin: 569 items in index
08:49:17 DEBUG: SearchManager: Starting search for 'q'
08:49:17 DEBUG: AppsPlugin: Found qemu.desktop for 'q'
08:49:17 ERROR: Failed to get search results from apps
Traceback (most recent call last):
  File "/tmp/catapult-devel.git/catapult/search.py", line 59, in _get_results
    for i, result in enumerate(plugin.search(query)):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/catapult-devel.git/catapult/plugins/apps.py", line 99, in search
    description=self._get_description(app),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/catapult-devel.git/catapult/plugins/apps.py", line 61, in _get_description
    description = re.sub(r" %\w\b", "", description)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/re/__init__.py", line 186, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
08:49:17 DEBUG: SearchManager: builtins delivered in 0 ms
08:49:17 DEBUG: SearchManager: Found 0 results
08:49:17 DEBUG: SearchManager: Adjusted scores in 0 ms
```
@otsaloma
Copy link
Owner

otsaloma commented Oct 9, 2024

Thanks for noticing, I haven't seen this on my system. If there's no command line, what are they? And specifically, are they launchable? i.e. will this work

def launch(self, window, id):
if not id in self._index: return
app = self._index[id]
self.debug(f"Launching {id}")
app.launch_uris(uris=None, context=None)

Because if they're not launchable, they should be left out of the index.

@UffeJakobsen
Copy link
Contributor Author

UffeJakobsen commented Oct 11, 2024

Thanks for noticing, I haven't seen this on my system. If there's no command line, what are they? And specifically, are they launchable? i.e. will this work

I'm currently working at another system - and here I can find this "empty" desktop file - and it is definitely not useful and/or launchable:

File: /usr/share/applications/qemu.desktop
Size: 134 B

[Desktop Entry]
Version=1.0
Name=QEMU
Icon=qemu
Type=Application
Terminal=false
Keywords=Emulators;Virtualization;KVM;
NoDisplay=true

PS: /usr/share/applications/qemu.desktop is owned by qemu-common package

PPS: I had more "empty" files on another installation that I currently cannot reach...

@otsaloma
Copy link
Owner

Merging with the check moved earlier, so that these apps are not indexed at all.

@otsaloma otsaloma merged commit 8b285ed into otsaloma:master Oct 11, 2024
1 check passed
@UffeJakobsen UffeJakobsen deleted the master_uj_handle_description_none branch October 12, 2024 11:26
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

Successfully merging this pull request may close these issues.

2 participants