Skip to content

Commit

Permalink
Protection for empty directory string when loading python Refs #5920
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Oct 8, 2012
1 parent b63c34d commit 68f33fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Code/Mantid/Framework/PythonInterface/mantid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def apiVersion():
plugin_dirs = kernel.config['pythonalgorithms.directories'].split(";")
plugin_files = []
for directory in plugin_dirs:
plugin_files += _plugins.find_plugins(directory)
try:
if directory != '':
plugin_files += _plugins.find_plugins(directory)
except ValueError, exc:
logger.warning(str(exc))
continue

# Mockup the full API first so that any Python algorithm module has something to import
_simpleapi.mockup(plugin_files)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ def run(self):
def find_plugins(top_dir):
"""
Searches recursively from the given directory to find the list of plugins that should be loaded
@param top_dir :: A string containing a path to a directory. Throws ValueError if it is not valid
"""
if not _os.path.isdir(top_dir):
raise ValueError("Cannot search given path for plugins, path is not a directory: %s " % str(top_dir))
raise ValueError("Cannot search given path for plugins, path is not a directory: '%s' " % str(top_dir))
plugins = []
for root, dirs, files in _os.walk(top_dir):
for f in files:
Expand Down

0 comments on commit 68f33fd

Please sign in to comment.