Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
autoupdate_branch: develop
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies = [
"tsam>=2.3.6",
"xarray==2024.9.0",
"xlrd==2.0.1",
"zipfile-deflate64==0.2.0"
]


Expand Down
27 changes: 19 additions & 8 deletions workflow/scripts/retrieve_databundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import zipfile
from pathlib import Path

import zipfile_deflate64 # For Windows OS, use zipfile-deflate64


def is_wsl():
with open("/proc/version") as f:
return "microsoft" in f.read().lower()


from _helpers import configure_logging, progress_retrieve

logger = logging.getLogger(__name__)
Expand All @@ -29,14 +37,17 @@ def download_repository(url, rootpath, repository):
progress_retrieve(url, tarball_fn)

logger.info(f"Extracting {repository} databundle.")
if (
repository == "EFS"
): # deflate64 compression not supported by zipFile, current subprocess command will only work on linux and mac
if platform.system() == "Windows":
cmd = ["tar", "-xf", tarball_fn, "-C", to_fn]
else:
cmd = ["unzip", tarball_fn, "-d", to_fn]
subprocess.run(cmd, check=True)
if repository == "EFS":
if platform.system() == "Windows" or is_wsl(): # Handle both Windows and WSL
try:
with zipfile_deflate64.ZipFile(tarball_fn, "r") as zip_ref:
zip_ref.extractall(to_fn)
except Exception as e:
logger.error(f"Failed to extract zip file with zipfile_deflate64: {e}")
raise
else: # Pure Linux environment
cmd = ["unzip", tarball_fn, "-d", str(to_fn)]
subprocess.run(cmd, check=True)
else:
with zipfile.ZipFile(tarball_fn, "r") as zip_ref:
zip_ref.extractall(to_fn)
Expand Down