Downloads Elasticsearch with specified plugins, setups them and starts
353998
public synchronized EmbeddedElastic start() throws IOException, InterruptedException {
        if (!started) {
            started = true;
            installElastic();
            startElastic();
            createRestClient();
            createTemplates();
            createIndices();
        }
        return this;
    }
247418
def probe_plugins():
    
    plugins = UwsgiRunner().get_plugins()

    for plugin in sorted(plugins.generic):
        click.secho(plugin)

    click.secho('')

    for plugin in sorted(plugins.request):
        click.secho(plugin)
194081
def run(opts, args):
        '''
        '''
        setup_options(opts)

        mode = Modes.ONCE
        if len(args) > 0 and hasattr(Modes, args[0].upper()):
            _mode = args.pop(0).upper()
            mode = getattr(Modes, _mode)

        url = None
        if len(args) > 0:
            # A url was specified
            url = args.pop(0)

        plugin_mgr = PluginManager.load_plugin_from_addonxml(mode, url)
        plugin_mgr.run()
1235942
function buildPluginEntry(plugins) {
    const result = {};
    plugins.forEach(
        plugin =>
            (result[path.basename(plugin, '.js')] = path.join(
                pluginSrcDir,
                plugin
            ))
    );
    return result;
}
519905
def plugins(cls, enabled=True):
        
        cls.loadPlugins()
        plugs = getattr(cls, '_%s__plugins' % cls.__name__, {}).values()
        if enabled is None:
            return plugs

        return filter(lambda x: x.isEnabled() == enabled, plugs)
835998
def load_plugins(group='metrics.plugin.10'):
    
    # on using entrypoints:
    # http://stackoverflow.com/questions/774824/explain-python-entry-points
    file_processors = []
    build_processors = []
    for ep in pkg_resources.iter_entry_points(group, name=None):
        log.debug('loading \'%s\'', ep)
        plugin = ep.load()  # load the plugin
        if hasattr(plugin, 'get_file_processors'):
            file_processors.extend(plugin.get_file_processors())
        if hasattr(plugin, 'get_build_processors'):
            build_processors.extend(plugin.get_build_processors())
    return file_processors, build_processors
1314980
function ElasticSearch () {
  var self = this;

  self.klass = ElasticSearch;
  self.klass.super_.apply(self, arguments);

  var auth = [
        self.options.server.username,
        self.options.server.password
      ].compact().join(':');

  self.options.server.auth = auth;
  self.options.server.protocol = undefined;
}
1143056
function buildGet (opts) {
  // eslint-disable-next-line no-unused-vars
  const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
  /**
   * Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request
   *
   * @param {string} id - The document ID
   * @param {string} index - The name of the index
   * @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types)
   * @param {list} stored_fields - A comma-separated list of stored fields to return in the response
   * @param {string} parent - The ID of the parent document
   * @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
   * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode
   * @param {boolean} refresh - Refresh the shard containing the document before performing the operation
   * @param {string} routing - Specific routing value
   * @param {list} _source - True or false to return the _source field or not, or a list of fields to return
   * @param {list} _source_excludes - A list of fields to exclude from the returned _source field
   * @param {list} _source_includes - A list of fields to extract and return from the _source field
   * @param {number} version - Explicit version number for concurrency control
   * @param {enum} version_type - Specific version type
   */

  const acceptedQuerystring = [
    'stored_fields',
    'parent',
    'preference',
    'realtime',
    'refresh',
    'routing',
    '_source',
    '_source_excludes',
    '_source_includes',
    'version',
    'version_type',
    'pretty',
    'human',
    'error_trace',
    'source',
    'filter_path'
  ]

  const snakeCase = {
    storedFields: 'stored_fields',
    _sourceExcludes: '_source_excludes',
    _sourceIncludes: '_source_includes',
    versionType: 'version_type',
    errorTrace: 'error_trace',
    filterPath: 'filter_path'
  }

  return function get (params, options, callback) {
    options = options || {}
    if (typeof options === 'function') {
      callback = options
      options = {}
    }
    if (typeof params === 'function' || params == null) {
      callback = params
      params = {}
      options = {}
    }

    // check required parameters
    if (params['id'] == null) {
      const err = new ConfigurationError('Missing required parameter: id')
      return handleError(err, callback)
    }
    if (params['index'] == null) {
      const err = new ConfigurationError('Missing required parameter: index')
      return handleError(err, callback)
    }
    if (params.body != null) {
      const err = new ConfigurationError('This API does not require a body')
      return handleError(err, callback)
    }

    // validate headers object
    if (options.headers != null && typeof options.headers !== 'object') {
      const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
      return handleError(err, callback)
    }

    var warnings = []
    var { method, body, id, index, type, ...querystring } = params
    querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)

    if (method == null) {
      method = 'GET'
    }

    var ignore = options.ignore
    if (typeof ignore === 'number') {
      options.ignore = [ignore]
    }

    var path = ''

    if ((index) != null && (type) != null && (id) != null) {
      path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id)
    } else {
      path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id)
    }

    // build request object
    const request = {
      method,
      path,
      body: null,
      querystring
    }

    options.warnings = warnings.length === 0 ? null : warnings
    return makeRequest(request, options, callback)
  }
}
328543
function start(config) {
		if (!isConfigurationParametersDefinedCorrectly(config)) {
			throw new Error('license-check - Configuration error');
		}

		var folders = [];
		if (config.src) {
			folders = getFoldersToCheck(config.src);
		}

		if (folders.length === 0) {
			gutil.log('license-check', gutil.colors.red('{src} not defined or empty, the plugin will run with the default configuration: **/*'));
			folders = getDefaultFolders();
		}

		var src = vfs.src(folders);
		src.pipe(license(config));
		return src;
	}
441301
def get_plugins(**kwargs):
    
    
    plugins = []
    plugin_paths = []
    
    #Look in directory or set of directories for
    #plugins
    
    base_plugin_dir = config.get('plugin', 'default_directory')
    plugin_xsd_path = config.get('plugin', 'plugin_xsd_path')

    base_plugin_dir_contents = os.listdir(base_plugin_dir)
    for directory in base_plugin_dir_contents:
        #ignore hidden files
        if directory[0] == '.' or directory == 'xml':
            continue

        #Is this a file or a directory? If it's a directory, it's a plugin.
        path = os.path.join(base_plugin_dir, directory)
        if os.path.isdir(path):
            plugin_paths.append(path)
   

    #For each plugin, get its details (an XML string)
    
    #Retrieve the xml schema for validating the XML to make sure
    #what is being provided  to the IU is correct.
    xmlschema_doc = etree.parse(plugin_xsd_path)
                    
    xmlschema = etree.XMLSchema(xmlschema_doc)
    
    #Get the xml description file from the plugin directory. If there
    #is no xml file, the plugin in unusable.
    for plugin_dir in plugin_paths:
        full_plugin_path = os.path.join(plugin_dir, 'trunk')
        
        dir_contents = os.listdir(full_plugin_path)
        #look for a plugin.xml file in the plugin directory 
        for file_name in dir_contents:
            file_path = os.path.join(full_plugin_path, file_name)
            if file_name == 'plugin.xml':
                
                f = open(file_path, 'r')
                
                #validate the xml using the xml schema for defining
                #plugin details
                try:
                    y = open(file_path, 'r')
                    
                    xml_tree = etree.parse(y)

                    xmlschema.assertValid(xml_tree)
                   
                    plugins.append(etree.tostring(xml_tree))
                except Exception as e:
                    log.critical("Schema %s did not validate! (error was %s)"%(file_name, e))

                break
        else:
            log.warning("No xml plugin details found for %s. Ignoring", plugin_dir)

    return plugins
1243563
def install(self, plugin, name=None, **opts):
        """"""
        source = plugin

        if isinstance(plugin, str):
            module, _, attr = plugin.partition(':')
            module = import_module(module)
            plugin = getattr(module, attr or 'Plugin', None)

        if isinstance(plugin, types.ModuleType):
            plugin = getattr(module, 'Plugin', None)

        if plugin is None:
            raise MuffinException('Plugin is not found %r' % source)

        name = name or plugin.name
        if name in self.ps:
            raise MuffinException('Plugin with name `%s` is already intalled.' % name)

        if isinstance(plugin, type):
            plugin = plugin(**opts)

        if hasattr(plugin, 'setup'):
            plugin.setup(self)

        if hasattr(plugin, 'middleware') and plugin.middleware not in self.middlewares:
            self.middlewares.append(plugin.middleware)

        if hasattr(plugin, 'startup'):
            self.on_startup.append(plugin.startup)

        if hasattr(plugin, 'cleanup'):
            self.on_cleanup.append(plugin.cleanup)

        # Save plugin links
        self.ps[name] = plugin

        return plugin
932006
def init(self):
        """"""
        if not self.export_enable:
            return None

        self.index='{}-{}'.format(self.index, datetime.utcnow().strftime("%Y.%m.%d"))
        template_body =  {
          "mappings": {
            "glances": {
              "dynamic_templates": [
                {
                  "integers": {
                    "match_mapping_type": "long",
                    "mapping": {
                      "type": "integer"
                    }
                  }
                },
                {
                  "strings": {
                    "match_mapping_type": "string",
                    "mapping": {
                      "type": "text",
                      "fields": {
                        "raw": {
                          "type":  "keyword",
                          "ignore_above": 256
                        }
                      }
                    }
                  }
                }
              ]
            }
          }
        }

        try:
            es = Elasticsearch(hosts=['{}:{}'.format(self.host, self.port)])
        except Exception as e:
            logger.critical("Cannot connect to ElasticSearch server %s:%s (%s)" % (self.host, self.port, e))
            sys.exit(2)
        else:
            logger.info("Connected to the ElasticSearch server %s:%s" % (self.host, self.port))

        try:
            index_count = es.count(index=self.index)['count']
        except Exception as e:
            # Index did not exist, it will be created at the first write
            # Create it...
            es.indices.create(index=self.index,body=template_body)
        else:
            logger.info("The index %s exists and holds %s entries." % (self.index, index_count))

        return es
477624
def setup_geoserver(options):
    from geonode.settings import INSTALLED_APPS, OGC_SERVER
    """"""
    # only start if using Geoserver backend
    _backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
    if (_backend == 'geonode.qgis_server'
            or 'geonode.geoserver' not in INSTALLED_APPS):
        return

    download_dir = path('downloaded')
    if not download_dir.exists():
        download_dir.makedirs()

    geoserver_dir = path('geoserver')

    geoserver_bin = download_dir / \
        os.path.basename(dev_config['GEOSERVER_URL'])
    jetty_runner = download_dir / \
        os.path.basename(dev_config['JETTY_RUNNER_URL'])

    grab(
        options.get('geoserver', dev_config['GEOSERVER_URL']), geoserver_bin,
        "geoserver binary")
    grab(
        options.get('jetty', dev_config['JETTY_RUNNER_URL']), jetty_runner,
        "jetty runner")

    if not geoserver_dir.exists():
        geoserver_dir.makedirs()

        webapp_dir = geoserver_dir / 'geoserver'
        if not webapp_dir:
            webapp_dir.makedirs()

        print 'extracting geoserver'
        z = zipfile.ZipFile(geoserver_bin, "r")
        z.extractall(webapp_dir)

    _install_data_dir()
572978
def create_logstash(self, **kwargs):
        
        logstash = predix.admin.logstash.Logging(**kwargs)
        logstash.create()
        logstash.add_to_manifest(self)

        logging.info('Install Kibana-Me-Logs application by following GitHub instructions')
        logging.info('git clone https://github.com/cloudfoundry-community/kibana-me-logs.git')

        return logstash
472716
def load_all_plugins(self):
        """"""

        # Go through the existing python files in the plugin directory
        self.plugin_path = os.path.realpath(self.plugin_dir)
        sys.path.append(self.plugin_dir)
        print '<<< Plugin Manager >>>'
        for f in [os.path.join(self.plugin_dir, child) for child in os.listdir(self.plugin_dir)]:

            # Skip certain files
            if '.DS_Store' in f or '__init__.py' in f: 
                continue

            # Add the plugin
            self.add_plugin(f)
867744
function loadPlugins(deps) {
  let pluginsList = deps;
  if (!Array.isArray(pluginsList)) {
    if (typeof pluginsList !== 'object') {
      return;
    }
    pluginsList = Object.keys(pluginsList);
  }
  pluginsList.filter(moduleName => /@gilt-tech\/swig-(?!util)/.test(moduleName))
    .forEach(load);
}
217237
def create_mapping(self):
        """"""
        try:
            self.document_class.init()
            self._mapping_created = True
        except IllegalOperation as error:
            if error.args[0].startswith('You cannot update analysis configuration'):
                # Ignore mapping update errors, which are thrown even when the analysis
                # configuration stays the same.
                # TODO: Remove this when https://github.com/elastic/elasticsearch-dsl-py/pull/272 is merged.
                return

            raise