Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils.download() should report the url when a download fails #697

Closed
grahamgower opened this issue Nov 19, 2020 · 0 comments · Fixed by #1285
Closed

utils.download() should report the url when a download fails #697

grahamgower opened this issue Nov 19, 2020 · 0 comments · Fixed by #1285

Comments

@grahamgower
Copy link
Member

E.g. if a url cannot be found, the following error appears from the test suite.

Traceback (most recent call last):
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/site-packages/nose/suite.py", line 210, in run
    self.setUp()
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/site-packages/nose/suite.py", line 293, in setUp
    self.setupContext(ancestor)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/site-packages/nose/suite.py", line 316, in setupContext
    try_run(context, names)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "/home/runner/work/stdpopsim/stdpopsim/tests/test_genetic_maps.py", line 37, in setUpModule
    utils.download(genetic_map.url, local_file)
  File "/home/runner/work/stdpopsim/stdpopsim/stdpopsim/utils.py", line 70, in download
    with urllib.request.urlopen(url, timeout=30) as f_in:
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/share/miniconda/envs/stdpopsim/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

Probably we should catch the exception in utils.download(), print the url, then reraise the exception. Or maybe there's a way to add information to an exception before reraising?

grahamgower added a commit to grahamgower/stdpopsim that referenced this issue Jun 1, 2022
grahamgower added a commit to grahamgower/stdpopsim that referenced this issue Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant