From ddc7e07ea1caddd4f6bdaecd8b2b03e647bea065 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 22 Aug 2016 18:09:57 +0530 Subject: [PATCH] Use shutil instead of distuils for which() It is unusual to use distuils outside of setup scripts. --- plinth/action_utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plinth/action_utils.py b/plinth/action_utils.py index a680efad5..fbf5e285e 100644 --- a/plinth/action_utils.py +++ b/plinth/action_utils.py @@ -20,10 +20,10 @@ Python action utility functions. """ from django.utils.translation import ugettext as _ -from distutils import spawn import os import logging import psutil +import shutil import socket import subprocess import tempfile @@ -122,16 +122,16 @@ def service_reload(service_name): def webserver_is_enabled(name, kind='config'): """Return whether a config/module/site is enabled in Apache.""" + if not shutil.which('a2query'): + return False + option_map = {'config': '-c', 'site': '-s', 'module': '-m'} - if spawn.find_executable('a2query'): - try: - # Don't print anything on the terminal - subprocess.check_output(['a2query', option_map[kind], name], - stderr=subprocess.STDOUT) - return True - except subprocess.CalledProcessError: - return False - else: + try: + # Don't print anything on the terminal + subprocess.check_output(['a2query', option_map[kind], name], + stderr=subprocess.STDOUT) + return True + except subprocess.CalledProcessError: return False