Skip to content

Commit

Permalink
Merge pull request #4459 from branfosj/enhance_download_instructions
Browse files Browse the repository at this point in the history
Enhance download instructions
  • Loading branch information
boegel committed Feb 27, 2024
2 parents eadfdc7 + 3e8632f commit af15883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import traceback
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from textwrap import indent

import easybuild.tools.environment as env
import easybuild.tools.toolchain as toolchain
Expand Down Expand Up @@ -953,7 +954,8 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
if download_instructions is None:
download_instructions = self.cfg['download_instructions']
if download_instructions is not None and download_instructions != "":
msg = "\nDownload instructions:\n\n" + download_instructions + '\n'
msg = "\nDownload instructions:\n\n" + indent(download_instructions, ' ') + '\n\n'
msg += "Make the files available in the active source path: %s\n" % ':'.join(source_paths())
print_msg(msg, prefix=False, stderr=True)
error_msg += "please follow the download instructions above, and make the file available "
error_msg += "in the active source path (%s)" % ':'.join(source_paths())
Expand Down
12 changes: 8 additions & 4 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,8 @@ def test_download_instructions(self):
self.assertErrorRegex(EasyBuildError, error_pattern, eb.fetch_step)
stderr = self.get_stderr().strip()
self.mock_stderr(False)
self.assertIn("Download instructions:\n\nManual download from example.com required", stderr)
self.assertIn("Download instructions:\n\n Manual download from example.com required", stderr)
self.assertIn("Make the files available in the active source path", stderr)

# create dummy source file
write_file(os.path.join(os.path.dirname(self.eb_file), 'software_with_missing_sources-0.0.tar.gz'), '')
Expand All @@ -1596,7 +1597,8 @@ def test_download_instructions(self):
stderr = self.get_stderr().strip()
self.mock_stderr(False)
self.mock_stdout(False)
self.assertIn("Download instructions:\n\nManual download from example.com required", stderr)
self.assertIn("Download instructions:\n\n Manual download from example.com required", stderr)
self.assertIn("Make the files available in the active source path", stderr)

# wipe top-level download instructions, try again
self.contents = self.contents.replace(download_instructions, '')
Expand Down Expand Up @@ -1625,7 +1627,8 @@ def test_download_instructions(self):
stderr = self.get_stderr().strip()
self.mock_stderr(False)
self.mock_stdout(False)
self.assertIn("Download instructions:\n\nExtension sources must be downloaded via example.com", stderr)
self.assertIn("Download instructions:\n\n Extension sources must be downloaded via example.com", stderr)
self.assertIn("Make the files available in the active source path", stderr)

# download instructions should also be printed if 'source_tmpl' is used to specify extension sources
self.contents = self.contents.replace(sources, "'source_tmpl': SOURCE_TAR_GZ,")
Expand All @@ -1638,7 +1641,8 @@ def test_download_instructions(self):
stderr = self.get_stderr().strip()
self.mock_stderr(False)
self.mock_stdout(False)
self.assertIn("Download instructions:\n\nExtension sources must be downloaded via example.com", stderr)
self.assertIn("Download instructions:\n\n Extension sources must be downloaded via example.com", stderr)
self.assertIn("Make the files available in the active source path", stderr)

# create dummy source file for extension
write_file(os.path.join(os.path.dirname(self.eb_file), 'ext_with_missing_sources-0.0.tar.gz'), '')
Expand Down

0 comments on commit af15883

Please sign in to comment.