<s> """<STR_LIT>""" <EOL> from fabric . api import ( <EOL> abort , <EOL> hide , <EOL> settings , <EOL> ) <EOL> from fabric . colors import red <EOL> from fabtools . apache import ( <EOL> disable_module , <EOL> enable_module , <EOL> disable_site , <EOL> enable_site , <EOL> _site_config_path , <EOL> ) <EOL> from fabtools . service import reload as reload_service <EOL> from fabtools . system import UnsupportedFamily , distrib_family <EOL> from fabtools . utils import run_as_root <EOL> from fabtools . require . files import template_file <EOL> from fabtools . require . service import started as require_started <EOL> def server ( ) : <EOL> """<STR_LIT>""" <EOL> family = distrib_family ( ) <EOL> if family == '<STR_LIT>' : <EOL> _server_debian ( ) <EOL> else : <EOL> raise UnsupportedFamily ( supported = [ '<STR_LIT>' ] ) <EOL> def _server_debian ( ) : <EOL> from fabtools . require . deb import package as require_deb_package <EOL> require_deb_package ( '<STR_LIT>' ) <EOL> require_started ( '<STR_LIT>' ) <EOL> def module_enabled ( module ) : <EOL> """<STR_LIT>""" <EOL> enable_module ( module ) <EOL> reload_service ( '<STR_LIT>' ) <EOL> def module_disabled ( module ) : <EOL> """<STR_LIT>""" <EOL> disable_module ( module ) <EOL> reload_service ( '<STR_LIT>' ) <EOL> def site_enabled ( config ) : <EOL> """<STR_LIT>""" <EOL> enable_site ( config ) <EOL> reload_service ( '<STR_LIT>' ) <EOL> def site_disabled ( config ) : <EOL> """<STR_LIT>""" <EOL> disable_site ( config ) <EOL> reload_service ( '<STR_LIT>' ) <EOL> def site ( site_name , template_contents = None , template_source = None , enabled = True , check_config = True , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> server ( ) <EOL> config_path = _site_config_path ( site_name ) <EOL> context = { <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> } <EOL> context . update ( kwargs ) <EOL> context [ '<STR_LIT>' ] = site_name <EOL> template_file ( config_path , template_contents , template_source , context , use_sudo = True ) <EOL> if enabled : <EOL> enable_site ( site_name ) <EOL> else : <EOL> disable_site ( site_name ) <EOL> if check_config : <EOL> with settings ( hide ( '<STR_LIT>' , '<STR_LIT>' ) , warn_only = True ) : <EOL> if run_as_root ( '<STR_LIT>' ) . failed : <EOL> disable_site ( site_name ) <EOL> message = red ( "<STR_LIT>" % locals ( ) ) <EOL> abort ( message ) <EOL> reload_service ( '<STR_LIT>' ) <EOL> enabled = site_enabled <EOL> disabled = site_disabled <EOL> __all__ = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ] </s>
