From 6ca627d705392b0c0ea15c678823fa18f8da3000 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Sun, 10 Jan 2021 15:30:35 +0100 Subject: [PATCH] more safeguards against not converted programs in the database --- CHANGELOG | 3 +++ engine/findprograms.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b954d2c..e9543d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-15-01 0.2.1 +Remove Nuitka as dependency. Build commands stay the same. + 2020-12-05 0.2.0 Fix crash from Qt/PyQt regression with Qt 5.15.2 Install nsm-data manpage diff --git a/engine/findprograms.py b/engine/findprograms.py index 894f407..fd07214 100644 --- a/engine/findprograms.py +++ b/engine/findprograms.py @@ -203,7 +203,7 @@ class SupportedProgramsDatabase(object): def _exeToDesktopEntry(self, exe:str)->dict: """Assumes self.desktopEntries is up to date Convert one exe (not full path!) to one dict entry. """ - if exe in self.knownDesktopFiles: #Shortcut through internal database + if exe in self.knownDesktopFiles and type(self.knownDesktopFiles[exe]) is dict : #Shortcut through internal database entry = self.knownDesktopFiles[exe] return entry else: #Reverse Search desktop files. @@ -211,7 +211,6 @@ class SupportedProgramsDatabase(object): if "exec" in entry and exe.lower() in entry["exec"].lower(): return entry #else: #Foor loop ended. Did not find any matching desktop file - return None def _build(self): @@ -224,8 +223,7 @@ class SupportedProgramsDatabase(object): for exe, fullPath in self.executables: self.progressHook(f"{fullPath}") entry = self._exeToDesktopEntry(exe) - if entry: #Found match! - assert type(entry) is dict, type(entry) + if entry and type(entry) is dict: #Found match! entry["agordejoFullPath"] = fullPath #We don't want .desktop syntax like "qmidiarp %F" entry["agordejoExec"] = exe @@ -245,6 +243,9 @@ class SupportedProgramsDatabase(object): leftovers.remove((exe,fullPath)) except KeyError: pass #Double entries like zyn-jack zyn-alsa etc. + elif entry and not type(entry) is dict: + #There is a strange bug I can't reproduce. At least catch it. + logger.error(f"Wrong entry type: {type(entry)} for {entry}") for exe,fullPath in leftovers: pseudoEntry = {"name": exe.title(), "agordejoExec":exe, "agordejoFullPath":fullPath}