Internal function, ensure all plugin packages are imported.
18172
def _import_plugins(self):
        
        if self.detected:
            return

        # In some cases, plugin scanning may start during a request.
        # Make sure there is only one thread scanning for plugins.
        self.scanLock.acquire()
        if self.detected:
            return  # previous threaded released + completed

        try:
            import_apps_submodule("content_plugins")
            self.detected = True
        finally:
            self.scanLock.release()
1071175
def collect(basepath, exclude=None, processPlugins=True):
    
    if exclude is None:
        exclude = ['.py', '.pyc', '.pyo', '.css', '.exe']

    imports = []
    datas = []

    # walk the folder structure looking for all packages and data files
    basename = os.path.basename(basepath)
    basepath = os.path.abspath(basepath)
    baselen = len(basepath) - len(basename)

    plugfiles = []

    for root, folders, files in os.walk(basepath):
        if '.svn' in root or '.git' in root:
            continue

        # mark the plugins file for load
        plugdata = None
        if processPlugins and '__plugins__.py' in files:
            filename = os.path.join(root, '__plugins__.py')
            package = projex.packageFromPath(filename) + '.__plugins__'
            pkgpath = projex.packageRootPath(filename)

            if pkgpath not in sys.path:
                sys.path.insert(0, pkgpath)

            # import the plugins module
            __import__(package)
            pkg = sys.modules[package]

            recurse = getattr(pkg, '__recurse__', False)
            plugdata = {'recurse': recurse,
                        'packages': [],
                        'path': root}

            plugfiles.append(plugdata)

        # look for any recursion plugins
        else:
            for data in plugfiles:
                if data['recurse'] and root.startswith(data['path']):
                    plugdata = data
                    break

        if plugdata is not None:
            packages = plugdata['packages']

            # include package plugins
            for folder in folders:
                pkgpath = os.path.join(root, folder, '__init__.py')
                if os.path.exists(pkgpath):
                    packages.append(projex.packageFromPath(pkgpath))

        for file_ in files:
            module, ext = os.path.splitext(file_)

            # look for python modules
            if ext == '.py':
                package_path = projex.packageFromPath(os.path.join(root, file_))
                if not package_path:
                    continue

                if module != '__init__':
                    package_path += '.' + module

                imports.append(package_path)

                # test to see if this is a plugin file
                if plugdata is not None and module not in ('__init__',
                                                           '__plugins__'):
                    plugdata['packages'].append(package_path)

            # look for data
            elif ext not in exclude:
                src = os.path.join(root, file_)
                targ = os.path.join(root[baselen:])
                datas.append((src, targ))

    # save the plugin information
    for plugdata in plugfiles:
        fname = os.path.join(plugdata['path'], '__plugins__.py')
        packages = plugdata['packages']

        plugs = ',\n'.join(map(lambda x: "r'{0}'".format(x), packages))
        data = [
            '__recurse__ = {0}'.format(plugdata['recurse']),
            '__toc__ = [{0}]'.format(plugs)
        ]

        # write the data to the system
        f = open(fname, 'w')
        f.write('\n'.join(data))
        f.close()

    return imports, datas
394634
def force_single_imports(self):
        """"""
        for import_stmt in self.imports[:]:
            import_info = import_stmt.import_info
            if import_info.is_empty() or import_stmt.readonly:
                continue
            if len(import_info.names_and_aliases) > 1:
                for name_and_alias in import_info.names_and_aliases:
                    if hasattr(import_info, "module_name"):
                        new_import = importinfo.FromImport(
                            import_info.module_name, import_info.level,
                            [name_and_alias])
                    else:
                        new_import = importinfo.NormalImport([name_and_alias])
                    self.add_import(new_import)
                import_stmt.empty_import()
1242384
def _load_needed_plugins(self):
        
        global plugin_recursive_store
        if "plugin_recursive_store" not in globals():
            plugin_recursive_store = []

        if self.name in plugin_recursive_store:
            self.log.warning("Plugin dependency loop detected: %s already checked and dependencies got activated" %
                             self.name)
            if self.app.strict:
                raise PluginDependencyLoop("Plugin dependency loop detected: %s already checked and dependencies "
                                           "got activated" % self.name)
            return False
        else:
            plugin_recursive_store.append(self.name)

        if not hasattr(self, "needed_plugins"):
            pass
        elif not isinstance(self.needed_plugins, tuple) and not isinstance(self.needed_plugins, list):
            raise TypeError("needed_plugins must be a tuple or a list")
        elif len(self.needed_plugins) > 0:
            try:
                for needed_plugin in self.needed_plugins:
                    if not isinstance(needed_plugin, str):
                        raise TypeError("Plugin name must be a string, got %s" % type(needed_plugin).__name__)
                    # Check, if a plugin with this name got already activated
                    plugin = self.app.plugins.get(needed_plugin)
                    if plugin is not None and not plugin.active:
                        plugin.activate()
                    # If not, check if a plugin_class with this name is available and activate it
                    plugin_class = self.app.plugins.classes.get(needed_plugin)
                    if plugin_class is not None:
                        plugin_class(self.app, needed_plugin)
            except Exception:
                plugin_recursive_store.remove(self.name)
                return False

        plugin_recursive_store.remove(self.name)
        return True
958064
function resolveDependencyPaths(options) {
  function init(items) {
    // Invalid if not Array
    if (Array.isArray(items)) {
      items.forEach((item, idx, items) => {
        const isArray = Array.isArray(item);
        const id = isArray ? item[0] : item;

        // Ignore already resolved
        if ('string' == typeof id) {
          const filepath = dependencies.find(id);

          if (!filepath) return warn(`unable to load plugin ${strong(id)}`, 1);

          if (isArray) {
            item[0] = require(filepath);
          } else {
            items[idx] = require(filepath);
          }
        }
      });
    }
  }

  if (options.plugins) init(options.plugins);
  if (options.presets) init(options.presets);
}
812564
def activate():
    """"""

    global PathFinder, FileFinder, ff_path_hook

    path_hook_index = len(sys.path_hooks)
    sys.path_hooks.append(ff_path_hook)
    # Resetting sys.path_importer_cache values,
    # to support the case where we have an implicit package inside an already loaded package,
    # since we need to replace the default importer.
    sys.path_importer_cache.clear()

    # Setting up the meta_path to change package finding logic
    pathfinder_index = len(sys.meta_path)
    sys.meta_path.append(PathFinder)

    return path_hook_index, pathfinder_index
1140518
def is_plugin_installed(name):
    
    for directory in plugin_paths:
        if isdir(join(directory, name)):
            return True
    return False
145308
def load_plugins(self):
        
        try:
            from pkg_resources import iter_entry_points
        except ImportError:
            return
        for ep in iter_entry_points(group="custodian.%s" % self.plugin_type):
            f = ep.load()
            f()
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)
1082910
function all_installed_plugins(customParams, callback) {
      var _doArgs71 = doArgs(arguments, [['object', {}], 'function']);

      var _doArgs72 = _slicedToArray(_doArgs71, 2);

      customParams = _doArgs72[0];
      callback = _doArgs72[1];


      customParams.depth = 1;

      doRequest({
        urlPattern: [PLUGINS],
        failureStatusCodes: [HTTP_CODE_302],
        noparse: true,
        bodyProp: 'plugins'
      }, customParams, callback);
    }
945825
def add_plugin(plugin, directory=None):
    """"""
    repo = require_repo(directory)
    plugins = get_value(repo, 'plugins', expect_type=dict)
    if plugin in plugins:
        return False

    plugins[plugin] = {}
    set_value(repo, 'plugins', plugins)
    return True
764485
def load_plugins(self, ):
        
        for p in self.__plugins.values():
            try:
                self.load_plugin(p)
            except errors.PluginInitError:
                log.exception('Initializing the plugin: %s failed.' % p)
599426
private function requireAll()
    {
        $vendors = [];
        $plugins = $this->goals['plugins'];
        if ($plugins) {
            $file = File::create('.hidev/composer.json');
            $data = ArrayHelper::merge($file->load(), ['require' => $plugins]);
            if ($file->save($data) || !is_dir('.hidev/vendor')) {
                $this->updateDotHidev();
            }
            $vendors[] = $this->buildRootPath('.hidev/vendor');
        }
        if ($this->needsComposerInstall()) {
            if ($this->passthru('composer', ['install', '--ansi'])) {
                throw new InvalidParamException('Failed initialize project with composer install');
            }
        }
        $vendors[] = $this->buildRootPath('vendor');

        foreach ($vendors as $vendor) {
            foreach (['console', 'hidev'] as $name) {
                $path = ConfigPlugin::path($name, $vendor);
                if (file_exists($path)) {
                    $this->appFiles[] = $path;
                }
            }
        }
    }
552746
def set_plugins(self, input_plugins):
        """"""
        header = "glances_"
        for item in input_plugins:
            # Import the plugin
            try:
                plugin = __import__(header + item)
            except ImportError:
                # Server plugin can not be imported from the client side
                logger.error("Can not import {} plugin. Please upgrade your Glances client/server version.".format(item))
            else:
                # Add the plugin to the dictionary
                # The key is the plugin name
                # for example, the file glances_xxx.py
                # generate self._plugins_list["xxx"] = ...
                logger.debug("Server uses {} plugin".format(item))
                self._plugins[item] = plugin.Plugin(args=self.args)
        # Restoring system path
        sys.path = sys_path
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
21311
protected static function _init()
    {
        if (static::$_initialized) {
            return;
        }

        static::$_detectors['plugin'] = function ($package) {
            return static::_getPlugin($package);
        };

        static::$_detectors['library'] = function ($package) {
            return static::_getLibrary($package);
        };

        static::$_detectors['thirdParty'] = function ($package) {
            return static::_getThirdParty($package);
        };

        static::$_initialized = true;
    }
1278246
function resolveDependencyPlugins(deps) {
    return deps
        .filter(dep => isInstalled(dep) && isInstalled(`eslint-plugin-${dep}`))
        .map(dep => `./lib/plugin-conf/${dep}.js`);
}