make resolve_path robust against None path being provided#2282
Merged
wpoely86 merged 4 commits intoeasybuilders:developfrom Aug 9, 2017
Merged
make resolve_path robust against None path being provided#2282wpoely86 merged 4 commits intoeasybuilders:developfrom
wpoely86 merged 4 commits intoeasybuilders:developfrom
Conversation
vanzod
approved these changes
Aug 8, 2017
wpoely86
reviewed
Aug 9, 2017
| resolved_path = os.path.realpath(path) | ||
| except OSError as err: | ||
| raise EasyBuildError("Resolving path %s failed: %s", path, err) | ||
| if path is None: |
Member
There was a problem hiding this comment.
Shouldn't we just avoid calling this with None?
Member
Author
There was a problem hiding this comment.
@wpoely86 Well, sure, that's another option, but then we're bound to make the same mistake again later?
It would boil down to doing this in get_paths_for:
# figure out installation prefix, e.g. distutils install path for easyconfigs
eb_path = which('eb')
if eb_path is None:
_log.warning("'eb' not found in $PATH, failed to determine installation prefix")
else:
# real location of eb should reside in <install_prefix>/bin/eb
eb_path = resolve_path(eb_path)
install_prefix = os.path.dirname(os.path.dirname(eb_path))whereas now we have:
# figure out installation prefix, e.g. distutils install path for easyconfigs
eb_path = resolve_path(which('eb'))
if eb_path is None:
...I'm not sure which one is better, I'm happy to change it as you suggest if you feel strongly about it.
Member
Author
|
@wpoely86 Updated, this is indeed a bit cleaner, I don't think we want to go towards making every possible function robust against passing in None... |
…specified as path
wpoely86
approved these changes
Aug 9, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
companion fix for #2279 (alongside updated bootstrap script in #2281)
If this had been part of #2248, bootstrapping EasyBuild v3.3.1 would not have been broken as reported in #2279