mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +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,16 +122,16 @@ 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],
|
stderr=subprocess.STDOUT)
|
||||||
stderr=subprocess.STDOUT)
|
return True
|
||||||
return True
|
except subprocess.CalledProcessError:
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user