~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Martin Pool
  • Date: 2005-07-11 03:40:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050711034002-575d84b4c7514542
- commit command refuses unless something is changed or --unchanged is given

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    _loaded = True
57
57
 
58
58
    import sys, os, imp
59
 
    
 
59
    try:
 
60
        set
 
61
    except NameError:
 
62
        from sets import Set as set         # python2.3
 
63
 
60
64
    from bzrlib.trace import log_error, mutter, log_exception
61
65
    from bzrlib.errors import BzrError
62
 
    from bzrlib import plugins
63
66
 
64
 
    dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(":")
65
 
    dirs.insert(0, os.path.dirname(plugins.__file__))
 
67
    bzrpath = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH)
66
68
 
67
69
    # The problem with imp.get_suffixes() is that it doesn't include
68
70
    # .pyo which is technically valid
72
74
    suffixes = imp.get_suffixes()
73
75
    suffixes.append(('.pyo', 'rb', imp.PY_COMPILED))
74
76
    package_entries = ['__init__.py', '__init__.pyc', '__init__.pyo']
75
 
    for d in dirs:
 
77
    for d in bzrpath.split(os.pathsep):
76
78
        # going through them one by one allows different plugins with the same
77
79
        # filename in different directories in the path
78
80
        mutter('looking for plugins in %s' % d)
112
114
                try:
113
115
                    plugin = imp.load_module('bzrlib.plugin.' + name,
114
116
                                             *plugin_info)
115
 
                    all_plugins.append(plugin)
 
117
                    all_plugins.append(plugin_info)
116
118
                finally:
117
119
                    if plugin_info[0] is not None:
118
120
                        plugin_info[0].close()
119
 
 
120
 
                mutter('loaded succesfully')
121
 
            except:
 
121
            except Exception, e:
122
122
                log_error('Unable to load plugin %r from %r' % (name, d))
 
123
                log_error(str(e))
123
124
                log_exception()
124
125