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

Commits:

2 changed files:

Changes:

  • src/plugins/gui.py
    ... ... @@ -114,6 +114,11 @@ class PluginsWindow(object):
    114 114
             self.plugins_notebook.set_current_page(0)
    
    115 115
             self.xml.get_object('close_button').grab_focus()
    
    116 116
     
    
    117
    +        for plugin in gajim.plugin_manager.active_plugins:
    
    118
    +            if type(plugin).__name__ == 'PluginInstaller':
    
    119
    +                plugin.on_activate(self)
    
    120
    +                break
    
    121
    +
    
    117 122
             self.window.show_all()
    
    118 123
             gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
    
    119 124
     
    

  • src/plugins/pluginmanager.py
    ... ... @@ -403,20 +403,25 @@ class PluginManager(metaclass=Singleton):
    403 403
     
    
    404 404
         @staticmethod
    
    405 405
         @log_calls('PluginManager')
    
    406
    -    def scan_dir_for_plugins(path, scan_dirs=True):
    
    406
    +    def scan_dir_for_plugins(path, scan_dirs=True, package=False):
    
    407 407
             r'''
    
    408 408
             Scans given directory for plugin classes.
    
    409 409
     
    
    410 410
             :param path: directory to scan for plugins
    
    411 411
             :type path: str
    
    412 412
     
    
    413
    +        :param scan_dirs: folders inside path are processed as modules
    
    414
    +        :type scan_dirs: boolean
    
    415
    +
    
    416
    +        :param package: if path points to a single package folder
    
    417
    +        :type package: boolean
    
    418
    +
    
    413 419
             :return: list of found plugin classes (subclasses of `GajimPlugin`
    
    414 420
             :rtype: [] of class objects
    
    415 421
     
    
    416 422
             :note: currently it only searches for plugin classes in '\*.py' files
    
    417 423
                     present in given direcotory `path` (no recursion here)
    
    418 424
     
    
    419
    -        :todo: add scanning packages
    
    420 425
             :todo: add scanning zipped modules
    
    421 426
             '''
    
    422 427
             from plugins.plugins_i18n import _
    
    ... ... @@ -427,7 +432,11 @@ class PluginManager(metaclass=Singleton):
    427 432
             if not os.path.isdir(path):
    
    428 433
                 return plugins_found
    
    429 434
     
    
    430
    -        dir_list = os.listdir(path)
    
    435
    +        if package:
    
    436
    +            path, package_name = os.path.split(path)
    
    437
    +            dir_list = [package_name]
    
    438
    +        else:
    
    439
    +            dir_list = os.listdir(path)
    
    431 440
     
    
    432 441
             sys.path.insert(0, path)
    
    433 442
     
    
    ... ... @@ -439,6 +448,8 @@ class PluginManager(metaclass=Singleton):
    439 448
                 elif os.path.isdir(file_path) and scan_dirs:
    
    440 449
                     module_name = elem_name
    
    441 450
                     file_path += os.path.sep
    
    451
    +            else:
    
    452
    +                continue
    
    442 453
     
    
    443 454
                 manifest_path = os.path.join(os.path.dirname(file_path),
    
    444 455
                     'manifest.ini')
    
    ... ... @@ -482,11 +493,14 @@ class PluginManager(metaclass=Singleton):
    482 493
     
    
    483 494
                 module = None
    
    484 495
     
    
    485
    -            if module_name in sys.modules:
    
    486
    -            # do not load the module twice
    
    487
    -                continue
    
    488 496
                 try:
    
    489
    -                module = __import__(module_name)
    
    497
    +                if module_name in sys.modules:
    
    498
    +                    from imp import reload
    
    499
    +                    log.info('Reloading %s', module_name)
    
    500
    +                    module = reload(sys.modules[module_name])
    
    501
    +                else:
    
    502
    +                    log.info('Loading %s', module_name)
    
    503
    +                    module = __import__(module_name)
    
    490 504
                 except Exception as error:
    
    491 505
                     log.warning(
    
    492 506
                         "While trying to load {plugin}, exception occurred".format(plugin=elem_name),