Use shutil instead of distuils for which()

It is unusual to use distuils outside of setup scripts.
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2016-08-26 21:51:55 -04:00
1 parent 31c6f866e2
commit ddc7e07ea1
1 file changed
+10 -10
+10 -10
View File
@@ -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