Skip to content

Commit afe4fcd

Browse files
authored
Merge pull request #4005 from Louwrensth/fixup_tweak_printing_of_download_instructions
fix printing of list of attempted download URLs when url-encoded characters are used in URL
2 parents 89860bd + 4fd33f3 commit afe4fcd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,10 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
883883
error_msg += "please follow the download instructions above, and make the file available "
884884
error_msg += "in the active source path (%s)" % ':'.join(source_paths())
885885
else:
886+
# flatten list to string with '%' characters escaped (literal '%' desired in 'sprintf')
887+
failedpaths_msg = ', '.join(failedpaths).replace('%', '%%')
886888
error_msg += "and downloading it didn't work either... "
887-
error_msg += "Paths attempted (in order): %s " % ', '.join(failedpaths)
889+
error_msg += "Paths attempted (in order): %s " % failedpaths_msg
888890

889891
raise EasyBuildError(error_msg, filename)
890892

test/framework/easyblock.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,12 @@ def test_obtain_file(self):
16941694
error_regex = "Couldn't find file %s anywhere, and downloading it didn't work either" % fn
16951695
self.assertErrorRegex(EasyBuildError, error_regex, eb.obtain_file, fn, urls=['file://%s' % tmpdir_subdir])
16961696

1697+
# also test triggering error when downloading from a URL that includes URL-encoded characters
1698+
# cfr. https://github.com/easybuilders/easybuild-framework/pull/4005
1699+
url = 'file://%s' % os.path.dirname(tmpdir_subdir)
1700+
url += '%2F' + os.path.basename(tmpdir_subdir)
1701+
self.assertErrorRegex(EasyBuildError, error_regex, eb.obtain_file, fn, urls=[url])
1702+
16971703
# file specifications via URL also work, are downloaded to (first) sourcepath
16981704
init_config(args=["--sourcepath=%s:/no/such/dir:%s" % (tmpdir, sandbox_sources)])
16991705
urls = [

0 commit comments

Comments
 (0)