Throw a useful error in the log when FileBrowser fails to load because of missing pywin32
This is a quick hack so that anyone else who runs this from source doesn't have to spend the time I spent tracking down why directory.list failed silently. There are two options that are much cleaner that come to mind: - Subclass ImportException so as to differentiate missing requirements from parse errors etc. - Provide a method for plugins to list their requirements, so that the loader can be the one to use imp.find_module(). Using imp.find_module() seems wise, either way.
This commit is contained in:
@@ -6,7 +6,15 @@ import os
|
||||
import string
|
||||
|
||||
if os.name == 'nt':
|
||||
import win32file
|
||||
import imp
|
||||
try:
|
||||
imp.find_module('win32file')
|
||||
except:
|
||||
# todo:: subclass ImportError for missing dependencies, vs. broken plugins?
|
||||
raise ImportError("Missing the win32file module, which is a part of the prerequisite \
|
||||
pywin32 package. You can get it from http://sourceforge.net/projects/pywin32/files/pywin32/");
|
||||
else:
|
||||
import win32file
|
||||
|
||||
class FileBrowser(Plugin):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user