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