def cli(ctx, dname, site):
    """
    Enable the <site> under the specified <domain>
    """
    assert isinstance(ctx, Context)

    dname = domain_parse(dname).hostname
    domain = Session.query(Domain).filter(Domain.name == dname).first()
    if not domain:
        click.secho('No such domain: {dn}'.format(dn=dname), fg='red', bold=True, err=True)
        return

    site_name = site
    site = Site.get(domain, site_name)
    if not site:
        click.secho('No such site: {site}'.format(site=site_name), fg='red', bold=True, err=True)
        return

    p = Echo('Constructing paths and configuration files...')
    site.enable()
    p.done()

    # Restart Nginx
    p = Echo('Restarting web server...')
    FNULL = open(os.devnull, 'w')
    subprocess.check_call(['service', 'nginx', 'restart'], stdout=FNULL, stderr=subprocess.STDOUT)
    p.done()
def cli ( ctx , dname , site ) : assert isinstance ( ctx , Context ) dname = domain_parse ( dname ) . hostname domain = Session . query ( Domain ) . filter ( Domain . name == dname ) . first ( ) if not domain : click . secho ( 'No such domain: {dn}' . format ( dn = dname ) , fg = 'red' , bold = True , err = True ) return site_name = site site = Site . get ( domain , site_name ) if not site : click . secho ( 'No such site: {site}' . format ( site = site_name ) , fg = 'red' , bold = True , err = True ) return p = Echo ( 'Constructing paths and configuration files...' ) site . enable ( ) p . done ( ) p = Echo ( 'Restarting web server...' ) FNULL = open ( os . devnull , 'w' ) subprocess . check_call ( [ 'service' , 'nginx' , 'restart' ] , stdout = FNULL , stderr = subprocess . STDOUT ) p . done ( )
Enable the <site> under the specified <domain>