def load(path=None): """ Search the plugin path for modules that provide a plugin. If path is a directory then search the directory for plugins. If path is None then use the default plugins path, bauble.plugins. This method populates the pluginmgr.plugins dict and imports the plugins but doesn't do any plugin initialization. :param path: the path where to look for the plugins :type path: str """ if path is None: if bauble.main_is_frozen(): #path = os.path.join(paths.lib_dir(), 'library.zip') path = os.path.join(paths.main_dir(), 'library.zip') else: path = os.path.join(paths.lib_dir(), 'plugins') logger.debug('pluginmgr.load(%s)' % path) found, errors = _find_plugins(path) logger.debug('found=%s, errors=%s' % (found, errors)) # show error dialog for plugins that couldn't be loaded...we only # give details for the first error and assume the others are the # same...and if not then it doesn't really help anyways if errors: name = ', '.join(sorted(errors.keys())) exc_info = errors.values()[0] exc_str = utils.xml_safe(exc_info[1]) tb_str = ''.join(traceback.format_tb(exc_info[2])) utils.message_details_dialog('Could not load plugin: ' '\n\n<i>%s</i>\n\n%s' % (name, exc_str), tb_str, type=gtk.MESSAGE_ERROR) if len(found) == 0: logger.debug('No plugins found at path: %s' % path) for plugin in found: # issue #27: should we include the module name of the plugin to # allow for plugin namespaces or just assume that the plugin class # name is unique? if isinstance(plugin, (type, types.ClassType)): plugins[plugin.__name__] = plugin logger.debug("registering plugin %s: %s" % (plugin.__name__, plugin)) else: plugins[plugin.__class__.__name__] = plugin logger.debug("registering plugin %s: %s" % (plugin.__class__.__name__, plugin))
return False """ return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")) # tools/freeze if main_is_frozen(): # main is frozen # put library.zip first in the path when using py2exe so libxml2 # gets imported correctly, zipfile = sys.path[-1] sys.path.insert(0, zipfile) # put the bundled gtk at the beginning of the path to make it the # preferred version os.environ['PATH'] = '%s%s%s%s%s%s' \ % (os.pathsep, os.path.join(paths.main_dir(), 'gtk', 'bin'), os.pathsep, os.path.join(paths.main_dir(), 'gtk', 'lib'), os.pathsep, os.environ['PATH']) # if not hasattr(gtk.Widget, 'set_tooltip_markup'): # msg = _('Bauble requires GTK+ version 2.12 or greater') # utils.message_dialog(msg, gtk.MESSAGE_ERROR) # sys.exit(1) # make sure we look in the lib path for modules sys.path.append(paths.lib_dir()) #if False: # sys.stderr.write('sys.path: %s\n' % sys.path) # sys.stderr.write('PATH: %s\n' % os.environ['PATH'])
return False """ return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")) # tools/freeze if main_is_frozen(): # main is frozen # put library.zip first in the path when using py2exe so libxml2 # gets imported correctly, zipfile = sys.path[-1] sys.path.insert(0, zipfile) # put the bundled gtk at the beginning of the path to make it the # preferred version os.environ['PATH'] = '%s%s%s%s%s%s' \ % (os.pathsep, os.path.join(paths.main_dir(), 'gtk', 'bin'), os.pathsep, os.path.join(paths.main_dir(), 'gtk', 'lib'), os.pathsep, os.environ['PATH']) # if not hasattr(gtk.Widget, 'set_tooltip_markup'): # msg = _('Bauble requires GTK+ version 2.12 or greater') # utils.message_dialog(msg, gtk.MESSAGE_ERROR) # sys.exit(1) # make sure we look in the lib path for modules sys.path.append(paths.lib_dir()) #sys.stderr.write('sys.path: %s\n' % sys.path) #sys.stderr.write('PATH: %s\n' % os.environ['PATH'])