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
This commit is contained in:
parent
6a84960811
commit
aca7307452
1 changed files with 38 additions and 19 deletions
|
|
@ -50,25 +50,6 @@ except ImportError:
|
|||
|
||||
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 @@ class SAT(service.Service):
|
|||
|
||||
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 @@ class SAT(service.Service):
|
|||
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 @@ class SAT(service.Service):
|
|||
|
||||
def stopService(self):
|
||||
log.info(u"Salut aussi à Rantanplan")
|
||||
return self.pluginsUnload()
|
||||
|
||||
def run(self):
|
||||
log.debug(_("running app"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue