Skip to content
Merged
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
4 changes: 3 additions & 1 deletion tools/download_zenodo_public.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ then
fi

echo "Downloading Zenodo record $projectID to $zenodo_dir..."
$python -m zenodo_get --output-dir=$zenodo_dir $projectID

# Use zenodo_get_ci.py wrapper which handles CI detection and progress bar suppression
$python tools/zenodo_get_ci.py --output-dir=$zenodo_dir $projectID

if [ $? -eq 0 ]; then
echo "Download completed successfully!"
Expand Down
55 changes: 55 additions & 0 deletions tools/zenodo_get_ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""
Wrapper for zenodo_get that suppresses progress bar in CI environments.

This script wraps the zenodo_get module to provide a CI-friendly interface
that suppresses the animated progress bar while preserving all informational
messages. It detects CI environments via the CI environment variable.

Usage:
python3 tools/zenodo_get_ci.py [ZENODO_GET_OPTIONS]

Examples:
# Download all files from a Zenodo record
python3 tools/zenodo_get_ci.py --output-dir=zenodo-123456 123456

# Use sandbox
python3 tools/zenodo_get_ci.py --sandbox --output-dir=zenodo-123456 123456

Environment Variables:
CI - When set, suppresses the progress bar by redirecting stdout to /dev/null

Behavior:
- In CI environments (CI env var set): Progress bar is suppressed
- In interactive environments: Progress bar is shown normally
- All informational messages are preserved (they go to stderr)

Note:
The zenodo_get module writes informational messages to stderr via eprint(),
while the progress bar from the wget library writes to stdout. This allows
us to suppress only the progress bar by redirecting stdout.
"""

import os
import sys

# Import zenodo_get first
from zenodo_get import zget

if __name__ == '__main__':
# Suppress progress bar in CI by redirecting stdout to /dev/null
if os.getenv("CI"):
# Save original stdout
original_stdout = sys.stdout
# Redirect stdout to /dev/null to suppress progress bar
sys.stdout = open(os.devnull, 'w')

try:
zget.cli()
finally:
# Restore stdout
sys.stdout.close()
sys.stdout = original_stdout
else:
# Normal mode - show progress bar
zget.cli()