checking for apache2 installation

- checking whether apache2 is configured or not before checking
  whether it is enabled

- changed python2 syntax to python3

- returning False
This commit is contained in:
nikhilrayaprolu 2016-07-23 19:20:29 +05:30 committed by James Valleroy
parent a7b2914990
commit eca8b8d42e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -20,6 +20,7 @@ Python action utility functions.
"""
from django.utils.translation import ugettext as _
from distutils import spawn
import os
import logging
import psutil
@ -121,12 +122,15 @@ def service_reload(service_name):
def webserver_is_enabled(name, kind='config'):
"""Return whether a config/module/site is enabled in Apache."""
option_map = {'config': '-c', 'site': '-s', 'module': '-m'}
try:
# Don't print anything on the terminal
subprocess.check_output(['a2query', option_map[kind], name],
stderr=subprocess.STDOUT)
return True
except subprocess.CalledProcessError:
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:
return False