Esempio n. 1
0
    def _mountapps(self):
        """Create application wise settings, using special section
        [mountloc], if any. Also parse referred configuration files."""
        from pluggdapps.plugin import pluginnames, webapps

        settings = self.settings

        # context for parsing ini files.
        _vars = {"here": abspath(dirname(self.inifile))}

        # Fetch special section [mountloc]. And override them with [DEFAULT]
        # settings.
        cp = SafeConfigParser()
        cp.read(self.inifile)
        if cp.has_section("mountloc"):
            mountloc = cp.items("mountloc", vars=_vars)
        else:
            mountloc = []
        settings["mountloc"] = dict(mountloc)
        settings.pop("here", None)  # TODO : how `here` gets populated.

        # Parse mount configuration.
        appsecs = list(map(h.plugin2sec, webapps()))
        mountls = []
        _skipopts = list(_vars.keys()) + list(settings["DEFAULT"].keys())
        for netpath, mounton in mountloc:
            if netpath in _skipopts:
                continue

            parts = [x.strip() for x in mounton.split(",", 1)]
            appname = parts.pop(0)
            configini = parts.pop(0) if parts else None
            appsec = h.plugin2sec(appname)

            if appsec not in appsecs:
                raise Exception("%r application not found." % appname)
            if not configini:
                raise Exception("configuration file %r not supplied" % configini)
            if not isfile(configini):
                raise Exception("configuration file %r not valid" % configini)

            mountls.append((appsec, netpath, configini))

        # Load application configuration from instance configuration file.
        appsettings = {}
        for appsec, netpath, instconfig in mountls:
            appsett = deepcopy(settings)
            [appsett.pop(k) for k in SPECIAL_SECS]
            if instconfig:
                self._loadinstance(appsett, instconfig)
            appsettings[(appsec, netpath, instconfig)] = appsett
        return appsettings
Esempio n. 2
0
    def _mountapps(self):
        """Create application wise settings, using special section
        [mountloc], if any. Also parse referred configuration files."""
        from pluggdapps.plugin import pluginnames, webapps

        settings = self.settings

        # context for parsing ini files.
        _vars = {'here': abspath(dirname(self.inifile))}

        # Fetch special section [mountloc]. And override them with [DEFAULT]
        # settings.
        cp = SafeConfigParser()
        cp.read(self.inifile)
        if cp.has_section('mountloc'):
            mountloc = cp.items('mountloc', vars=_vars)
        else:
            mountloc = []
        settings['mountloc'] = dict(mountloc)
        settings.pop('here', None)  # TODO : how `here` gets populated.

        # Parse mount configuration.
        appsecs = list(map(h.plugin2sec, webapps()))
        mountls = []
        _skipopts = list(_vars.keys()) + list(settings['DEFAULT'].keys())
        for netpath, mounton in mountloc:
            if netpath in _skipopts: continue

            parts = [x.strip() for x in mounton.split(',', 1)]
            appname = parts.pop(0)
            configini = parts.pop(0) if parts else None
            appsec = h.plugin2sec(appname)

            if appsec not in appsecs:
                raise Exception("%r application not found." % appname)
            if not configini:
                raise Exception("configuration file %r not supplied" %
                                configini)
            if not isfile(configini):
                raise Exception("configuration file %r not valid" % configini)

            mountls.append((appsec, netpath, configini))

        # Load application configuration from instance configuration file.
        appsettings = {}
        for appsec, netpath, instconfig in mountls:
            appsett = deepcopy(settings)
            [appsett.pop(k) for k in SPECIAL_SECS]
            if instconfig:
                self._loadinstance(appsett, instconfig)
            appsettings[(appsec, netpath, instconfig)] = appsett
        return appsettings
Esempio n. 3
0
    def _ls_summary(self, args):
        import pluggdapps

        webapps_ = webapps()
        print("Pluggdapps environment")
        print("  Configuration file : %s" % self.pa.inifile)
        print("  Erlang Port        : %s" % (self.pa.erlport or None))
        print("  Loaded packages    : %s" % len(pluggdapps.papackages))
        print("  Interfaces defined : %s" % len(PluginMeta._interfmap))
        print("  Plugins loaded     : %s" % len(PluginMeta._pluginmap))
        print("  Applications loaded: %s" % len(webapps_))
        print("Web-application instances")
        pprint(webapps_, indent=2)