Use shutil.which to check for existence of executable instead

This commit is contained in:
Veronica K. B. Olsen
2020-08-04 21:36:24 +02:00
parent 565be8c580
commit c58b5e71d0
2 changed files with 10 additions and 10 deletions
+10 -9
View File
@@ -33,7 +33,7 @@ import nw
from os import path, mkdir, unlink, rename from os import path, mkdir, unlink, rename
from time import time from time import time
from distutils import spawn from shutil import which
from PyQt5.Qt import PYQT_VERSION_STR from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo from PyQt5.QtCore import QT_VERSION_STR, QStandardPaths, QSysInfo
@@ -203,9 +203,8 @@ class Config:
self.kernelVer = "Unknown" self.kernelVer = "Unknown"
# Packages # Packages
self.hasEnchant = False self.hasEnchant = False # The pyenchant package
self.hasSymSpell = False self.hasAssistant = False # The Qt Assistant executable
self.hasAssistant = False # The Qt Assistant
# Recent Cache # Recent Cache
self.recentProj = {} self.recentProj = {}
@@ -896,17 +895,19 @@ class Config:
try: try:
import enchant import enchant
self.hasEnchant = True self.hasEnchant = True
logger.debug("Checking package pyenchant: Ok") logger.debug("Checking package 'pyenchant': Ok")
except: except:
self.hasEnchant = False self.hasEnchant = False
logger.debug("Checking package pyenchant: Missing") logger.debug("Checking package 'pyenchant': Missing")
try: try:
self.hasAssistant = spawn.find_executable("assistant") self.hasAssistant = which("assistant")
logger.debug("Checking executable assistant: Ok")
except: except:
self.hasAssistant = False self.hasAssistant = False
logger.debug("Checking executable assistant: Missing") if self.hasAssistant:
logger.debug("Checking executable 'assistant': Ok")
else:
logger.debug("Checking executable 'assistant': Missing")
return return
-1
View File
@@ -43,7 +43,6 @@ class NWSpellCheck():
SP_INTERNAL = "internal" SP_INTERNAL = "internal"
SP_ENCHANT = "enchant" SP_ENCHANT = "enchant"
SP_SYMSPELL = "symspell"
theDict = None theDict = None
PROJW = [] PROJW = []