Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/plugins/pluginmanager.py
    ... ... @@ -110,7 +110,7 @@ class PluginManager(metaclass=Singleton):
    110 110
             '''
    
    111 111
     
    
    112 112
             for path in reversed(configpaths.get_plugin_dirs()):
    
    113
    -            pc = PluginManager.scan_dir_for_plugins(path)
    
    113
    +            pc = self.scan_dir_for_plugins(path)
    
    114 114
                 self.add_plugins(pc)
    
    115 115
     
    
    116 116
         @log_calls('PluginManager')
    
    ... ... @@ -137,7 +137,6 @@ class PluginManager(metaclass=Singleton):
    137 137
             and adding class from reloaded module or ignoring adding plug-in?
    
    138 138
             '''
    
    139 139
             plugin = plugin_class()
    
    140
    -
    
    141 140
             if plugin not in self.plugins:
    
    142 141
                 if not self._plugin_has_entry_in_global_config(plugin):
    
    143 142
                     self._create_plugin_entry_in_global_config(plugin)
    
    ... ... @@ -520,9 +519,8 @@ class PluginManager(metaclass=Singleton):
    520 519
         def _set_plugin_active_in_global_config(self, plugin, active=True):
    
    521 520
             app.config.set_per('plugins', plugin.short_name, 'active', active)
    
    522 521
     
    
    523
    -    @staticmethod
    
    524 522
         @log_calls('PluginManager')
    
    525
    -    def scan_dir_for_plugins(path, scan_dirs=True, package=False):
    
    523
    +    def scan_dir_for_plugins(self, path, scan_dirs=True, package=False):
    
    526 524
             r'''
    
    527 525
             Scans given directory for plugin classes.
    
    528 526
     
    
    ... ... @@ -584,6 +582,21 @@ class PluginManager(metaclass=Singleton):
    584 582
                                     elem_name, exc_info=True)
    
    585 583
                         continue
    
    586 584
     
    
    585
    +            short_name = conf.get('info', 'short_name', fallback=None)
    
    586
    +            if short_name is None:
    
    587
    +                log.error('No short_name defined for %s', elem_name)
    
    588
    +
    
    589
    +            # Check if the plugin is already loaded
    
    590
    +            try:
    
    591
    +                for plugin in self.plugins:
    
    592
    +                    if plugin.short_name == short_name:
    
    593
    +                        raise PluginAlreadyLoaded(
    
    594
    +                            'Skip Plugin %s because its '
    
    595
    +                            'already loaded' % elem_name)
    
    596
    +            except PluginAlreadyLoaded as error:
    
    597
    +                log.warning(error)
    
    598
    +                continue
    
    599
    +
    
    587 600
                 min_v = conf.get('info', 'min_gajim_version', fallback=None)
    
    588 601
                 max_v = conf.get('info', 'max_gajim_version', fallback=None)
    
    589 602
     
    
    ... ... @@ -734,3 +747,7 @@ class PluginManager(metaclass=Singleton):
    734 747
             for plugin in self.plugins:
    
    735 748
                 if plugin.__path__ in plugin_dir:
    
    736 749
                     return plugin
    
    750
    +
    
    751
    +
    
    752
    +class PluginAlreadyLoaded(Exception):
    
    753
    +    pass