def _load_plugin(self, plugin, path): try: module_info = imp.find_module(plugin, [path]) module = imp.load_module(plugin, *module_info) iter = self._treemodel.append() self._treemodel.set(iter, COLUMN_ACTIVE, False, COLUMN_NAME, getattr(module,'__name'), COLUMN_MODULE, module, COLUMN_PATH, module_info[1], COLUMN_VERSION, getattr(module,'__version'), COLUMN_AUTHOR, getattr(module,'__author'), COLUMN_DESCRIPTION, getattr(module,'__description'), COLUMN_CLASS, getattr(module,'__class')) except ImportError, e: log.error('failed to load plugin: ' + plugin) log.error(e)
def _activate_plugin(self, iter): plugin = self._treemodel.get_value(iter, COLUMN_NAME) cls = self._treemodel.get_value(iter, COLUMN_CLASS) module = self._treemodel.get_value(iter, COLUMN_MODULE) instance = None try: attr = getattr(module, cls) instance = attr(self.app) except: log.error('Failed to activate plugin %s' % plugin) if instance: instance = None raise return None if isinstance(instance, Plugin): self._active_plugins.append((plugin, instance)) else: log.error('%s does not seem to be a valid Plugin' % instance) instance = None return None try: if instance.ui_info: instance.merge_id = self.app.ui.add_ui_from_string(instance.ui_info) self.app.ui.insert_action_group(instance.action_group, 0) except gobject.GError, msg: log.error('building menus failed: %s' % msg)
def error_cb(cmd, msg, args): log.error('error reading supported pids, msg is: %s' % msg) raise OBDPortError('OpenPortFailed', _('could not read supported pids\n\n' + msg))