Mercurial > libervia-backend
changeset 1550:465d4d484e7c
core: plugin unload:
Call unload() if it exists on all loaded plugin instances when leaving SàT. This method will probably be used later for hot (un)loading
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Nov 2015 22:02:41 +0100 |
parents | e987325c14ef |
children | 591c32dbfb0b |
files | src/core/sat_main.py |
diffstat | 1 files changed, 38 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/sat_main.py Mon Nov 02 22:02:41 2015 +0100 +++ b/src/core/sat_main.py Mon Nov 02 22:02:41 2015 +0100 @@ -50,25 +50,6 @@ class SAT(service.Service): - @property - def version(self): - """Return the short version of SàT""" - return C.APP_VERSION - - @property - def full_version(self): - """Return the full version of SàT (with extra data when in development mode)""" - version = self.version - if version[-1] == 'D': - # we are in debug version, we add extra data - try: - return self._version_cache - except AttributeError: - self._version_cache = u"{} ({})".format(version, utils.getRepositoryData(sat)) - return self._version_cache - else: - return version - def __init__(self): self._cb_map = {} # map from callback_id to callbacks self._menus = OrderedDict() # dynamic menus. key: callback_id, value: menu data (dictionnary) @@ -132,6 +113,25 @@ self.memory.initialized.addCallback(self._postMemoryInit) + @property + def version(self): + """Return the short version of SàT""" + return C.APP_VERSION + + @property + def full_version(self): + """Return the full version of SàT (with extra data when in development mode)""" + version = self.version + if version[-1] == 'D': + # we are in debug version, we add extra data + try: + return self._version_cache + except AttributeError: + self._version_cache = u"{} ({})".format(version, utils.getRepositoryData(sat)) + return self._version_cache + else: + return version + def _postMemoryInit(self, ignore): """Method called after memory initialization is done""" log.info(_("Memory initialised")) @@ -227,6 +227,24 @@ self.plugins[import_name].is_handler = False #TODO: test xmppclient presence and register handler parent + def pluginsUnload(self): + """Call unload method on every loaded plugin, if exists + + @return (D): A deferred which return None when all method have been called + """ + # TODO: in the futur, it should be possible to hot unload a plugin + # pluging depending on the unloaded one should be unloaded too + # for now, just a basic call on plugin.unload is done + defers_list = [] + for plugin in self.plugins.itervalues(): + try: + unload = plugin.unload + except AttributeError: + continue + else: + defers_list.append(defer.maybeDeferred(unload)) + return defers_list + def asyncConnect(self, profile_key=C.PROF_KEY_NONE, password=''): """Retrieve the individual parameters, authenticate the profile and initiate the connection to the associated XMPP server. @@ -445,6 +463,7 @@ def stopService(self): log.info(u"Salut aussi à Rantanplan") + return self.pluginsUnload() def run(self): log.debug(_("running app"))