addon improvements/fixes

- better error reporting when an addon fails to load
- upload an addon which loads partly but then fails (eg, module loads but class register fails)
- bugfix addon loading, failier to load would leave _bpy_types._register_immediate = False
- added which change on disk are reloaded when enabling.
- bpy.path.module_names() now returns (module_name, module_path) pairs.
This commit is contained in:
2010-09-08 07:30:20 +00:00
parent 1a41d2fc29
commit b58f41e120
4 changed files with 72 additions and 25 deletions

View File

@@ -183,7 +183,7 @@ def module_names(path, recursive=False):
:type path: string
:arg recursive: Also return submodule names for packages.
:type recursive: bool
:return: a list of strings.
:return: a list of string pairs (module_name, module_file).
:rtype: list
"""
@@ -193,13 +193,15 @@ def module_names(path, recursive=False):
for filename in sorted(_os.listdir(path)):
if filename.endswith(".py") and filename != "__init__.py":
modules.append(filename[0:-3])
fullpath = join(path, filename)
modules.append((filename[0:-3], fullpath))
elif ("." not in filename):
directory = join(path, filename)
if isfile(join(directory, "__init__.py")):
modules.append(filename)
fullpath = join(directory, "__init__.py")
if isfile(fullpath):
modules.append((filename, fullpath))
if recursive:
for mod_name in module_names(directory, True):
modules.append("%s.%s" % (filename, mod_name))
for mod_name, mod_path in module_names(directory, True):
modules.append(("%s.%s" % (filename, mod_name), mod_path))
return modules

View File

@@ -70,7 +70,7 @@ def modules_from_path(path, loaded_modules):
modules = []
for mod_name in _bpy.path.module_names(path):
for mod_name, mod_path in _bpy.path.module_names(path):
mod = _test_import(mod_name, loaded_modules)
if mod:
modules.append(mod)

View File

@@ -586,7 +586,8 @@ def _register_module(module):
bpy_types.register(t)
except:
import traceback
print("bpy.utils._register_module(): Module '%s' failed to register class '%s.%s'" % (module, t.__module__, t.__name__))
import sys
print("bpy.utils._register_module(): '%s' failed to register class '%s.%s'" % (sys.modules[module].__file__, t.__module__, t.__name__))
traceback.print_exc()