~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Robert Collins
  • Date: 2005-10-16 23:53:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016235302-818de607403e1c6e
test that the presence of a signature does not make a missing base file magically appear present

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
 
26
26
import os
27
 
from bzrlib.osutils import config_dir
 
27
import bzrlib
 
28
from bzrlib.config import config_dir
28
29
DEFAULT_PLUGIN_PATH = os.path.join(config_dir(), 'plugins')
29
30
 
30
31
all_plugins = []
59
60
    
60
61
    from bzrlib.trace import log_error, mutter, log_exception
61
62
    from bzrlib.errors import BzrError
 
63
    from bzrlib import plugins
62
64
 
63
 
    bzrpath = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH)
 
65
    dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(":")
 
66
    dirs.insert(0, os.path.dirname(plugins.__file__))
64
67
 
65
68
    # The problem with imp.get_suffixes() is that it doesn't include
66
69
    # .pyo which is technically valid
70
73
    suffixes = imp.get_suffixes()
71
74
    suffixes.append(('.pyo', 'rb', imp.PY_COMPILED))
72
75
    package_entries = ['__init__.py', '__init__.pyc', '__init__.pyo']
73
 
    for d in bzrpath.split(os.pathsep):
 
76
    for d in dirs:
74
77
        # going through them one by one allows different plugins with the same
75
78
        # filename in different directories in the path
76
79
        mutter('looking for plugins in %s' % d)
108
111
                plugin_info = imp.find_module(name, [d])
109
112
                mutter('load plugin %r' % (plugin_info,))
110
113
                try:
111
 
                    plugin = imp.load_module('bzrlib.plugin.' + name,
 
114
                    plugin = imp.load_module('bzrlib.plugins.' + name,
112
115
                                             *plugin_info)
113
116
                    all_plugins.append(plugin)
 
117
                    setattr(bzrlib.plugins, name, plugin)
114
118
                finally:
115
119
                    if plugin_info[0] is not None:
116
120
                        plugin_info[0].close()
117
 
            except Exception, e:
 
121
 
 
122
                mutter('loaded succesfully')
 
123
            except:
118
124
                log_error('Unable to load plugin %r from %r' % (name, d))
119
 
                log_error(str(e))
120
125
                log_exception()
121
126