コード例 #1
0
ファイル: __init__.py プロジェクト: dchusovitin/ajenti
    def load(self, name):
        """
        Loads given plugin
        """
        logging.debug("Loading plugin %s" % name)
        try:
            try:
                mod = imp.load_module(
                    "ajenti.plugins.%s" % name, *imp.find_module(name, [self.get_plugins_root(), self.extra_location])
                )
                if not hasattr(mod, "info"):
                    raise PluginFormatError()
            except PluginFormatError:
                raise
            except Exception, e:
                # TOTAL CRASH
                from ajenti.api import PluginInfo

                info = PluginInfo(name=name, crash=e)
                self.__plugins[name] = info
                raise PluginCrashed(e)

            info = mod.info
            info.module = mod
            info.active = False
            info.name = name
            info.path = mod.__path__[0]
            info.crash = None
            if hasattr(mod, "init"):
                info.init = mod.init
            self.__plugins[name] = info

            for dependency in info.dependencies:
                dependency.check()
            info.active = True

            try:
                info.init()
            except Exception, e:
                raise PluginCrashed(e)
コード例 #2
0
    def load(self, name):
        """
        Loads given plugin
        """
        logging.debug('Loading plugin %s' % name)
        try:
            try:
                mod = imp.load_module(
                    'ajenti.plugins.%s' % name,
                    *imp.find_module(
                        name, [self.get_plugins_root(), self.extra_location]))
                if not hasattr(mod, 'info'):
                    raise PluginFormatError()
            except PluginFormatError:
                raise
            except Exception, e:
                # TOTAL CRASH
                from ajenti.api import PluginInfo
                info = PluginInfo(name=name, crash=e)
                self.__plugins[name] = info
                raise PluginCrashed(e)

            info = mod.info
            info.module = mod
            info.active = False
            info.name = name
            info.path = mod.__path__[0]
            info.crash = None
            if hasattr(mod, 'init'):
                info.init = mod.init
            self.__plugins[name] = info

            for dependency in info.dependencies:
                dependency.check()
            info.active = True

            try:
                info.init()
            except Exception, e:
                raise PluginCrashed(e)
コード例 #3
0
ファイル: __init__.py プロジェクト: BrunIF/ajenti
    def load(self, name):
        """
        Loads given plugin
        """
        logging.debug('Loading plugin %s' % name)
        try:
            try:
                mod = imp.load_module('ajenti.plugins.%s' % name,
                                      *imp.find_module(name, [self.get_plugins_root(), self.extra_location]))
                if not hasattr(mod, 'info'):
                    raise PluginFormatError()
            except PluginFormatError:
                raise
            except Exception as e:
                # TOTAL CRASH
                from ajenti.api import PluginInfo
                info = PluginInfo(name=name, crash=e)
                self.__plugins[name] = info
                raise PluginCrashed(e)

            info = mod.info
            info.module = mod
            info.active = False
            info.name = name
            info.path = mod.__path__[0]
            info.crash = None
            if hasattr(mod, 'init'):
                info.init = mod.init
            self.__plugins[name] = info

            for dependency in info.dependencies:
                dependency.check()
            info.active = True

            try:
                info.init()
            except Exception as e:
                raise PluginCrashed(e)

            if name in self.__order:
                self.__order.remove(name)
            self.__order.append(name)

            return True
        except PluginDependency.Unsatisfied as e:
            raise
        except PluginFormatError as e:
            logging.warn(' *** [%s] Plugin error: %s' % (name, e))
        except PluginCrashed as e:
            logging.warn(' *** [%s] Plugin crashed: %s' % (name, e))
            print(e.traceback)
            info.crash = e
        except Dependency.Unsatisfied as e:
            logging.debug(' *** [%s] skipping due to %s' % (name, e))
            info.crash = e
        except PluginLoadError as e:
            logging.warn(' *** [%s] Plugin failed to load: %s' % (name, e))
            info.crash = e
コード例 #4
0
from ajenti.api import PluginInfo
from ajenti.plugins import PluginDependency

__version__ = "0.3"

info = PluginInfo(
    title='WonderShaper',
    icon=None,
    dependencies=[
        PluginDependency('main'),
    ],
)


def init():
    import main
コード例 #5
0
ファイル: __init__.py プロジェクト: surjit/ajenti_cp
    def load(self, name):
        """
        Loads given plugin
        """
        logging.debug('Loading plugin %s' % name)
        try:
            try:
                mod = imp.load_module(
                    'ajenti.plugins.%s' % name,
                    *imp.find_module(
                        name, [self.get_plugins_root(), self.extra_location]))
                if not hasattr(mod, 'info'):
                    raise PluginFormatError()
            except PluginFormatError:
                raise
            except Exception as e:
                # TOTAL CRASH
                from ajenti.api import PluginInfo
                info = PluginInfo(name=name, crash=e)
                self.__plugins[name] = info
                raise PluginCrashed(e)

            info = mod.info
            info.module = mod
            info.active = False
            info.name = name
            info.path = mod.__path__[0]
            info.crash = None
            if hasattr(mod, 'init'):
                info.init = mod.init
            self.__plugins[name] = info

            for dependency in info.dependencies:
                dependency.check()
            info.active = True

            try:
                info.init()
            except Exception as e:
                raise PluginCrashed(e)

            if name in self.__order:
                self.__order.remove(name)
            self.__order.append(name)

            return True
        except PluginDependency.Unsatisfied as e:
            raise
        except PluginFormatError as e:
            logging.warn(' *** [%s] Plugin error: %s' % (name, e))
        except PluginCrashed as e:
            logging.warn(' *** [%s] Plugin crashed: %s' % (name, e))
            print(e.traceback)
            info.crash = e
        except Dependency.Unsatisfied as e:
            logging.debug(' *** [%s] skipping due to %s' % (name, e))
            info.crash = e
        except PluginLoadError as e:
            logging.warn(' *** [%s] Plugin failed to load: %s' % (name, e))
            info.crash = e