Enable an available Nginx site.
482717
def enable_site(site_name):
    """"""

    site_available = u'/etc/nginx/sites-available/%s' % site_name
    site_enabled = u'/etc/nginx/sites-enabled/%s' % site_name
    if files.exists(site_available):
        sudo(u'ln -s -f %s %s' % (site_available, site_enabled))
        restart_service(u'nginx')
    else:
        abort(u'%s site configuration is not available' % site_name)
735460
def start_wsgi_server(port, addr='', registry=REGISTRY):
    """"""
    app = make_wsgi_app(registry)
    httpd = make_server(addr, port, app, handler_class=_SilentHandler)
    t = threading.Thread(target=httpd.serve_forever)
    t.daemon = True
    t.start()
1076990
def enable_sphinx_if_possible():
    """"""
    if SPHINX_INSTALLED:
        srcdir = tempfile.mkdtemp()
        outdir = os.path.join(srcdir, '_build')
        try:
            sphinx.application.Sphinx(srcdir=srcdir,
                                      confdir=None,
                                      outdir=outdir,
                                      doctreedir=outdir,
                                      buildername='dummy',
                                      status=None)
            yield
        finally:
            shutil.rmtree(srcdir)
    else:
        yield
808235
def _start_browsing_some_sites(self):
        '''
        
        '''
        # acquire_multi() raises NoBrowsersAvailable if none available
        browsers = self._browser_pool.acquire_multi(
                (self._browser_pool.num_available() + 1) // 2)
        try:
            sites = self._frontier.claim_sites(len(browsers))
        except:
            self._browser_pool.release_all(browsers)
            raise

        for i in range(len(browsers)):
            if i < len(sites):
                th = threading.Thread(
                        target=self._brozzle_site_thread_target,
                        args=(browsers[i], sites[i]),
                        name="BrozzlingThread:%s" % browsers[i].chrome.port,
                        daemon=True)
                with self._browsing_threads_lock:
                    self._browsing_threads.add(th)
                th.start()
            else:
                self._browser_pool.release(browsers[i])
1087775
def enable(self, folder):
		host_name = self.base.options.ip
		email = self.base.options.user
		isHost(host_name)
		self.__userExists(email)

		data = self.getHostData(host_name)
		website_dir = data['website_dir']
		full_path = '%s/%s' % (website_dir, folder)
		full_path_git = '%s/.git' % full_path
		repository = '%s/%s/%s.git' % (self.data[email]['dir'], host_name, folder)
		real_repository = '%s/%s.git' % (self.base.git['repositories'], host_name)
		user_hook = '%s/hooks/post-receive' % repository
		repo_hooks = '%s/.git/hooks' % website_dir
		origin = md5(email)

		if not fileExists(full_path):
			error_message('Folder %s not exists!' % full_path)

		if not host_name in self.data[email]['projects']:
			self.data[email]['projects'][host_name] = []

		if folder in self.data[email]['projects'][host_name]:
			error_message('Repository already exists for this user!')
		self.data[email]['projects'][host_name].append(folder)

		self.__makeDir(repository)
		os.system('cd %s && git init --bare 1> /dev/null' % repository)
		putFile(
			'%s/.gitignore' % full_path,
			getTemplate('git-jail-gitignore-default')
		)

		os.system(
			'cd %(full_path)s && git init 1> /dev/null && '
			'git remote add %(origin)s %(repository)s && '
			'git add . && '
			'git commit -am "Initial commit" 1> /dev/null && '
			'git push %(origin)s master 1> /dev/null' % locals()
		)

		os.system('chown git:git -R %s' % full_path)
		os.system('chown git:git -R %s' % repository)
		os.system('chown git:git -R %s' % real_repository)
		os.system('chown git:git -R %s/.git' % website_dir)


		'''
		
		'''

		key = hash('%(email)s-%(host_name)s-%(folder)s' % locals())

		templates = {
			user_hook: 'git-jail-post-receive-user-repo',
			'%s/post-commit' % repo_hooks: 'git-jail-post-commit-repo',
			'%s/post-receive' % repo_hooks: 'git-jail-post-receive-repo',
			'%s/hooks/post-receive' % real_repository: 'git-jail-post-receive-real-repo',
		}

		putFile(
			'%s/hooks/post-receive.db' % real_repository,
			'%(website_dir)s;%(full_path)s;.;%(key)s;%(origin)s;' % locals(),
			'a'
		)

		putFile(
			'%s.db' % user_hook,
			'%(full_path)s;%(website_dir)s;./%(folder)s/*;%(key)s;%(origin)s;' % locals(),
			'a'
		)

		putFile(
			'%s/post-receive.db' % repo_hooks,
			'%(full_path)s;%(real_repository)s;%(key)s;%(origin)s;' % locals(),
			'a'
		)

		for f,t in templates.items():
			putFile(f, getTemplate(t) % locals())
			os.system('chmod +x %s' % f)

		info_message('Successful!')
1204176
def publish(endpoint, purge_files, rebuild_manifest, skip_upload):
    """"""
    print("Publishing site to %s ..." % endpoint.upper())

    yass = Yass(CWD)
    target = endpoint.lower()

    sitename = yass.sitename
    if not sitename:
        raise ValueError("Missing site name")

    endpoint = yass.config.get("hosting.%s" % target)
    if not endpoint:
        raise ValueError("%s endpoint is missing in the config" % target.upper())

    if target == "s3":
        p = publisher.S3Website(sitename=sitename,
                                aws_access_key_id=endpoint.get("aws_access_key_id"),
                                aws_secret_access_key=endpoint.get("aws_secret_access_key"),
                                region=endpoint.get("aws_region"))

        if not p.website_exists:
            print(">>>")
            print("Setting S3 site...")
            if p.create_website() is True:
                # Need to give it enough time to create it
                # Should be a one time thing
                time.sleep(10)
                p.create_www_website()
                print("New bucket created: %s" % p.sitename)

        if rebuild_manifest:
            print(">>>")
            print("Rebuilding site's manifest...")
            p.create_manifest_from_s3_files()

        if purge_files is True or endpoint.get("purge_files") is True:
            print(">>>")
            print("Purging files...")
            exclude_files = endpoint.get("purge_exclude_files", [])
            p.purge_files(exclude_files=exclude_files)

        if not skip_upload:
            print(">>>")
            print("Uploading your site...")
            p.upload(yass.build_dir)
        else:
            print(">>>")
            print("WARNING: files upload was skipped because of the use of --skip-upload")

        print("")
        print("Yass! Your site has been successfully published to: ")
        print(p.website_endpoint_url)

    footer()
958925
def enable(name, **kwargs):
    '''
    
    '''
    cmd = '/usr/sbin/svcadm enable {0}'.format(name)
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
1275656
def open_ftp(self, url):
        """"""
        if not isinstance(url, str):
            raise URLError('ftp error: proxy support for ftp protocol currently not implemented')
        import mimetypes
        host, path = splithost(url)
        if not host: raise URLError('ftp error: no host given')
        host, port = splitport(host)
        user, host = splituser(host)
        if user: user, passwd = splitpasswd(user)
        else: passwd = None
        host = unquote(host)
        user = unquote(user or '')
        passwd = unquote(passwd or '')
        host = socket.gethostbyname(host)
        if not port:
            import ftplib
            port = ftplib.FTP_PORT
        else:
            port = int(port)
        path, attrs = splitattr(path)
        path = unquote(path)
        dirs = path.split('/')
        dirs, file = dirs[:-1], dirs[-1]
        if dirs and not dirs[0]: dirs = dirs[1:]
        if dirs and not dirs[0]: dirs[0] = '/'
        key = user, host, port, '/'.join(dirs)
        # XXX thread unsafe!
        if len(self.ftpcache) > MAXFTPCACHE:
            # Prune the cache, rather arbitrarily
            for k in self.ftpcache.keys():
                if k != key:
                    v = self.ftpcache[k]
                    del self.ftpcache[k]
                    v.close()
        try:
            if key not in self.ftpcache:
                self.ftpcache[key] = \
                    ftpwrapper(user, passwd, host, port, dirs)
            if not file: type = 'D'
            else: type = 'I'
            for attr in attrs:
                attr, value = splitvalue(attr)
                if attr.lower() == 'type' and \
                   value in ('a', 'A', 'i', 'I', 'd', 'D'):
                    type = value.upper()
            (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
            mtype = mimetypes.guess_type("ftp:" + url)[0]
            headers = ""
            if mtype:
                headers += "Content-Type: %s\n" % mtype
            if retrlen is not None and retrlen >= 0:
                headers += "Content-Length: %d\n" % retrlen
            headers = email.message_from_string(headers)
            return addinfourl(fp, headers, "ftp:" + url)
        except ftperrors() as exp:
            raise_with_traceback(URLError('ftp error %r' % exp))
1286593
def _allowAnotherAt(cls, parent):
        """"""
        site = parent.get_site()
        if site is None:
            return False
        return not cls.peers().descendant_of(site.root_page).exists()
625453
public static function configureAsRoot(): void
    {
        $filesystem = new Filesystem();
        $vendor_dir = Path::VENDOR_DIR . '/hostnet/phpcs-tool/src';
        if ($filesystem->exists($vendor_dir)) {
            return;
        }

        self::configure();

        $filesystem->mkdir($vendor_dir . '/Hostnet');
        $filesystem->symlink(__DIR__ . '/../../Sniffs', $vendor_dir . '/Hostnet/Sniffs');
        $filesystem->copy(__DIR__ . '/../../ruleset.xml', $vendor_dir . '/Hostnet/ruleset.xml');

        $filesystem->mkdir($vendor_dir . '/HostnetPaths');
        $filesystem->copy(__DIR__ . '/../../../HostnetPaths/ruleset.xml', $vendor_dir . '/HostnetPaths/ruleset.xml');
    }
84811
def upload_site(self):
        """"""
        if not os.path.isdir(self._config['build_dir']):
            message = 'Site not built at {0}'.format(self._config['build_dir'])
            self._logger.error(message)
            raise RuntimeError(message)

        ltdclient.upload(self._config)
921395
public function enableOldBrowserSupport(): self
    {
        $this->needsCompile = ($this->needsCompile || $this->supportOldBrowsers !== true);
        $this->supportOldBrowsers = true;
        return $this;
    }
1315851
def enable(name):
    '''
    
    '''
    cmd = 'systemctl enable systemd-nspawn@{0}'.format(name)
    if __salt__['cmd.retcode'](cmd, python_shell=False) != 0:
        __context__['retcode'] = salt.defaults.exitcodes.EX_UNAVAILABLE
        return False
    return True
1294609
def create_site(sitename):
    """"""
    sitepath = os.path.join(CWD, sitename)
    if os.path.isdir(sitepath):
        print("Site directory '%s' exists already!" % sitename)
    else:
        print("Creating site: %s..." % sitename)
        os.makedirs(sitepath)
        copy_resource("skel/", sitepath)
        stamp_yass_current_version(sitepath)
        print("Site created successfully!")
        print("CD into '%s' and run 'yass serve' to view the site" % sitename)

    footer()
828218
def setup(app):
    """"""
    app.add_config_value(
        'site_url',
        default=None,
        rebuild=False
    )
    try:
        app.add_config_value(
            'html_baseurl',
            default=None,
            rebuild=False
        )
    except:
        pass

    app.connect('html-page-context', add_html_link)
    app.connect('build-finished', create_sitemap)
    app.sitemap_links = []
    app.locales = []
905032
def enable(self, force=False):
        
        log = logging.getLogger('ipsv.models.sites.site')
        log.debug('Disabling all other sites under the domain %s', self.domain.name)
        Session.query(Site).filter(Site.id != self.id).filter(Site.domain == self.domain).update({'enabled': 0})

        sites_enabled_path = _cfg.get('Paths', 'NginxSitesEnabled')
        server_config_path = os.path.join(_cfg.get('Paths', 'NginxSitesAvailable'), self.domain.name)
        server_config_path = os.path.join(server_config_path, '{fn}.conf'.format(fn=self.slug))
        symlink_path = os.path.join(sites_enabled_path, '{domain}-{fn}'.format(domain=self.domain.name,
                                                                               fn=os.path.basename(server_config_path)))
        links = glob(os.path.join(sites_enabled_path, '{domain}-*'.format(domain=self.domain.name)))
        for link in links:
            if os.path.islink(link):
                log.debug('Removing existing configuration symlink: %s', link)
                os.unlink(link)
            else:
                if not force:
                    log.error('Configuration symlink path already exists, but it is not a symlink')
                    raise Exception('Misconfiguration detected: symlink path already exists, but it is not a symlink '
                                    'and --force was not passed. Unable to continue')
                log.warn('Configuration symlink path already exists, but it is not a symlink. Removing anyways '
                         'since --force was set')
                if os.path.isdir(symlink_path):
                    shutil.rmtree(symlink_path)
                else:
                    os.remove(symlink_path)

        log.info('Enabling Nginx configuration file')
        os.symlink(server_config_path, symlink_path)

        self.enabled = 1
        Session.commit()
1327399
def enable_service(conn, service='ceph'):
    
    if is_systemd(conn):
        remoto.process.run(
            conn,
            [
                'systemctl',
                'enable',
                '{service}'.format(service=service),
            ]
        )
    else:
        remoto.process.run(
            conn,
            [
                'chkconfig',
                '{service}'.format(service=service),
                'on',
            ]
        )