Skip to content

Commit

Permalink
Fix HTTPFileRetriever
Browse files Browse the repository at this point in the history
The output_dir was in the wrong place, so it was making a POST request.
  • Loading branch information
jfrost-mo committed Sep 16, 2024
1 parent 1ce5f15 commit acc401c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/CSET/_workflow_utils/fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ def get_file(self, file_path: str, output_dir: str) -> None:
Path to filesystem directory into which the file should be copied.
"""
ctx = ssl.create_default_context()
save_path = urllib.parse.urlparse(file_path).path.split("/")[-1]
with urllib.request.urlopen(file_path, output_dir, context=ctx) as response:
save_path = (
f"{output_dir.removesuffix('/')}/"
+ urllib.parse.urlparse(file_path).path.split("/")[-1]
)
with urllib.request.urlopen(file_path, context=ctx) as response:
with open(save_path, "wb") as fp:
# Read in 1 MiB chunks so data doesn't all have to be in memory.
while data := response.read(1024 * 1024):
Expand Down

0 comments on commit acc401c

Please sign in to comment.