~vorlon/ubuntu/saucy/gourmet/trunk

« back to all changes in this revision

Viewing changes to src/lib/plugin_loader.py

  • Committer: Bazaar Package Importer
  • Author(s): Rolf Leggewie
  • Date: 2009-01-12 23:03:28 UTC
  • mfrom: (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090112230328-wnuqqte22uk3981b
Tags: 0.14.3-2
Conflict with python-pysqlite >= 2.5 which when installed crashes 
gourmet at startup. (Closes: #507382) and python-sqlalchemy >= 0.5.
Both restrictions should eventually be relaxed when upstream has
made the code compatible with the newer libs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    # get_master_loader()
29
29
    __single = None
30
30
    default_active_plugin_sets = [
 
31
        # tools
31
32
        'unit_converter',
32
33
        'duplicate_finder',
33
34
        'key_editor',
 
35
        # import/export
34
36
        'gxml_plugin',
35
37
        'html_plugin',
 
38
        'mastercook_import_plugin',
 
39
        'mealmaster_plugin',
36
40
        'archive_plugin',
 
41
        'pdf_plugin',
 
42
        'plaintext_plugin',
 
43
        'web_import_plugin',
 
44
        'website_import_plugins',
 
45
        'krecipe_plugin',
37
46
        ]
38
47
    active_plugin_filename = os.path.join(gglobals.gourmetdir,'active_plugins')
39
48
 
78
87
        self.instantiated_plugins = {}
79
88
        for p in self.active_plugin_sets:
80
89
            if self.available_plugin_sets.has_key(p):
81
 
                self.active_plugins.extend(self.available_plugin_sets[p].plugins)
 
90
                try:
 
91
                    self.active_plugins.extend(self.available_plugin_sets[p].plugins)
 
92
                except:
 
93
                    import traceback
 
94
                    print 'WARNING: Failed to load plugin %s'%p
 
95
                    traceback.print_exc()
82
96
            else:
83
97
                print 'Plugin ',p,'not found'
84
98
 
171
185
                try:
172
186
                    plugin_instance = self.get_instantiated_plugin(p)
173
187
                except:
174
 
                    print 'Failed to instantiate plugin'
 
188
                    print 'WARNING: Failed to instantiate plugin %s of type %s'%(p,klass)
175
189
                    import traceback; traceback.print_exc()
176
190
                else:
177
191
                    #print 'Instantiating plugin',p,plugin_instance,'of',klass
218
232
                #print 'Loaded plugin set',self._loaded
219
233
                #print 'plugins=',self._loaded.plugins
220
234
            except ImportError:
 
235
                print 'WARNING: Plugin module import failed'
221
236
                print 'PATH:',sys.path
222
 
                raise
223
 
            return self._loaded
 
237
                import traceback; traceback.print_exc()
 
238
                return None
 
239
            else:
 
240
                return self._loaded
224
241
 
225
242
    def __getattr__ (self, attr):
226
243
        if attr == 'plugins': return self.get_plugins()
284
301
            self.plugins.append(plugin_instance)
285
302
            plugin_instance.activate(self)
286
303
        except:
287
 
            print 'PLUGIN FAILED TO LOAD'
 
304
            print 'WARNING: PLUGIN FAILED TO LOAD',plugin_instance
288
305
            import traceback; traceback.print_exc()
289
306
 
290
307
    def destroy (self):