Skip to content
Merged
11 changes: 10 additions & 1 deletion easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,23 +557,32 @@ def mod_exists_via_show(mod_name):
mod_exists_regex = r'\s*/.+:\s*'
for line in stderr.split('\n'):
# skip whitespace lines
self.log.debug("Checking line '%s' to determine whether %s exists...", line)
self.log.debug("Checking line '%s' to determine whether %s exists...", line, mod_name)
Comment thread
boegel marked this conversation as resolved.
if OUTPUT_MATCHES['whitespace'].search(line):
self.log.debug("Treating line '%s' as whitespace, so skipping it", line)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this overly verbose, even for debugging?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helped a lot with figuring out the problem reported in #3376, so no.

continue

# if any errors occured, conclude that module doesn't exist
if OUTPUT_MATCHES['error'].search(line):
self.log.debug("Line '%s' looks like an error, so concluding that %s doesn't exist", mod_name)
Comment thread
boegel marked this conversation as resolved.
Outdated
break

# skip warning lines, which may be produced by modules tool but should not be used
# to determine whether a module file exists
if line.startswith('WARNING: '):
Comment thread
boegel marked this conversation as resolved.
self.log.debug("Skipping warning line '%s'", line)
continue

# skip lines that start with 'module-' (like 'module-version'),
# see https://github.com/easybuilders/easybuild-framework/issues/3376
if line.startswith('module- '):
self.log.debug("Skipping line '%s' since it starts with 'module-version'", line)
Comment thread
boegel marked this conversation as resolved.
Outdated
continue

# if line matches pattern that indicates an existing module file, the module file exists
self.log.debug("Determining whether module %s exists using line '%s'", mod_name, line)
res = bool(re.match(mod_exists_regex, line))
self.log.debug("Result for existence check of %s based on 'module show' output: %s", mod_name, res)
Comment thread
boegel marked this conversation as resolved.
Outdated
break

return res
Expand Down