#!/usr/bin/env python
# coding=UTF-8

__author__ = 'Pierre-Yves Langlois'
__copyright__ = 'https://github.com/pylanglois/uwsa/blob/master/LICENCE'
__credits__ = ['Pierre-Yves Langlois']
__license__ = 'BSD'
__maintainer__ = 'Pierre-Yves Langlois'

from uwsas.common import *
from uwsas import core
from uwsas.core import L

def graceful():
    cmd_list = [
        "apache2ctl graceful",
    ]
    completed, pinfo = core.exec_cmd_list(cmd_list)
    if not completed:
        L.error(pinfo['stdout'] + '\n' + pinfo['stderr'])
        raise Exception(t("Error in site.graceful!"))

def enable(vhost):
    cmd_list = [
        "a2ensite %s" % vhost,
    ]
    completed, pinfo = core.exec_cmd_list(cmd_list)
    if not completed:
        raise Exception(t("Error in vhost activation!"), vhost)

