mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Use shutil instead of distuils for which()
It is unusual to use distuils outside of setup scripts.
This commit is contained in:
parent
31c6f866e2
commit
ddc7e07ea1
@ -20,10 +20,10 @@ 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
|
||||||
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -122,8 +122,10 @@ 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."""
|
||||||
|
if not shutil.which('a2query'):
|
||||||
|
return False
|
||||||
|
|
||||||
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],
|
||||||
@ -131,8 +133,6 @@ 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):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user