OnmyojiOmn
Prince
- Joined
- Aug 4, 2006
- Messages
- 371
Hi,
I just converted a mod for BUG's modular python system, and doing so took much longer than it should have because the lookupModule function in BugUtil discards ImportErrors:
I was able to figure out what I'd done wrong (incorrect imports) very quickly once I took out the try/except block. I don't know much about Python errors or whether you can wrap them, but ConfigError should at least include the original error message. "No such module" is probably the least likely cause of an ImportError being thrown here.
Somewhat related: speaking of python in BUG, we still need autoloading modules as of BUG 4.2. This business with init.xml is very crufty, and requiring users to edit XML to install a module is the difference between easy drag n' drop and a relatively complex installation process. Just load everything in contrib at startup and call it a day.
In any case, thank you for BUG. <3
I just converted a mod for BUG's modular python system, and doing so took much longer than it should have because the lookupModule function in BugUtil discards ImportErrors:
Code:
def lookupModule(module, log=True):
if log:
debug("BugUtil - looking up %s", module)
try:
return __import__(module)
except ImportError:
raise ConfigError("No such module '%s'", module)
I was able to figure out what I'd done wrong (incorrect imports) very quickly once I took out the try/except block. I don't know much about Python errors or whether you can wrap them, but ConfigError should at least include the original error message. "No such module" is probably the least likely cause of an ImportError being thrown here.
Somewhat related: speaking of python in BUG, we still need autoloading modules as of BUG 4.2. This business with init.xml is very crufty, and requiring users to edit XML to install a module is the difference between easy drag n' drop and a relatively complex installation process. Just load everything in contrib at startup and call it a day.
In any case, thank you for BUG. <3