From 0fcbad0fbcff9d0e9f003650e3a0d6ec0bee62ad Mon Sep 17 00:00:00 2001 From: ggman12 Date: Sat, 14 Feb 2026 15:07:08 -0500 Subject: [PATCH] let mictronics retry --- .../openairframes-daily-release.yaml | 26 +++++++++++++----- .../create_daily_microtonics_release.py | 27 ++++++++++++++----- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/openairframes-daily-release.yaml b/.github/workflows/openairframes-daily-release.yaml index 225f93b..0486f31 100644 --- a/.github/workflows/openairframes-daily-release.yaml +++ b/.github/workflows/openairframes-daily-release.yaml @@ -302,6 +302,7 @@ jobs: python-version: "3.14" - name: Run Mictronics DB release script + continue-on-error: true run: | python -m src.contributions.create_daily_microtonics_release ${{ inputs.date && format('--date {0}', inputs.date) || '' }} ls -lah data/openairframes @@ -312,11 +313,12 @@ jobs: name: mictronics-db path: data/openairframes/mictronics-db_*.zip retention-days: 1 + if-no-files-found: ignore create-release: runs-on: ubuntu-latest - needs: [build-faa, adsb-reduce, build-community] - if: github.event_name != 'schedule' + needs: [build-faa, adsb-reduce, build-community, build-adsbexchange-json, build-mictronics-db] + if: github.event_name != 'schedule' && !failure() && !cancelled() steps: - name: Checkout for gh CLI uses: actions/checkout@v4 @@ -351,6 +353,7 @@ jobs: - name: Download Mictronics DB artifact uses: actions/download-artifact@v4 + continue-on-error: true with: name: mictronics-db path: artifacts/mictronics @@ -405,8 +408,12 @@ jobs: if [ -z "$JSON_FILE_ADSBX" ] || [ ! -f "$JSON_FILE_ADSBX" ]; then MISSING_FILES="$MISSING_FILES ADSBX_JSON" fi + + # Optional files - warn but don't fail + OPTIONAL_MISSING="" if [ -z "$ZIP_FILE_MICTRONICS" ] || [ ! -f "$ZIP_FILE_MICTRONICS" ]; then - MISSING_FILES="$MISSING_FILES MICTRONICS_ZIP" + OPTIONAL_MISSING="$OPTIONAL_MISSING MICTRONICS_ZIP" + ZIP_FILE_MICTRONICS="" fi if [ -n "$MISSING_FILES" ]; then @@ -425,7 +432,14 @@ jobs: CSV_BASENAME_COMMUNITY=$(basename "$CSV_FILE_COMMUNITY" 2>/dev/null || echo "") ZIP_BASENAME=$(basename "$ZIP_FILE") JSON_BASENAME_ADSBX=$(basename "$JSON_FILE_ADSBX") - ZIP_BASENAME_MICTRONICS=$(basename "$ZIP_FILE_MICTRONICS") + ZIP_BASENAME_MICTRONICS="" + if [ -n "$ZIP_FILE_MICTRONICS" ]; then + ZIP_BASENAME_MICTRONICS=$(basename "$ZIP_FILE_MICTRONICS") + fi + + if [ -n "$OPTIONAL_MISSING" ]; then + echo "WARNING: Optional files missing:$OPTIONAL_MISSING (will continue without them)" + fi echo "date=$DATE" >> "$GITHUB_OUTPUT" echo "tag=$TAG" >> "$GITHUB_OUTPUT" @@ -463,7 +477,7 @@ jobs: with: tag_name: ${{ steps.meta.outputs.tag }} name: ${{ steps.meta.outputs.name }} - fail_on_unmatched_files: true + fail_on_unmatched_files: false body: | Automated daily snapshot generated at 06:00 UTC for ${{ steps.meta.outputs.date }}. @@ -473,7 +487,7 @@ jobs: - ${{ steps.meta.outputs.csv_basename_community }} - ${{ steps.meta.outputs.zip_basename }} - ${{ steps.meta.outputs.json_basename_adsbx }} - - ${{ steps.meta.outputs.zip_basename_mictronics }} + ${{ steps.meta.outputs.zip_basename_mictronics && format('- {0}', steps.meta.outputs.zip_basename_mictronics) || '' }} files: | ${{ steps.meta.outputs.csv_file_faa }} ${{ steps.meta.outputs.csv_file_adsb }} diff --git a/src/contributions/create_daily_microtonics_release.py b/src/contributions/create_daily_microtonics_release.py index 981c2d5..007b4e4 100644 --- a/src/contributions/create_daily_microtonics_release.py +++ b/src/contributions/create_daily_microtonics_release.py @@ -9,12 +9,17 @@ from __future__ import annotations import argparse import shutil +import sys +import time from datetime import datetime, timezone from pathlib import Path +from urllib.error import URLError from urllib.request import Request, urlopen URL = "https://www.mictronics.de/aircraft-database/indexedDB_old.php" OUT_ROOT = Path("data/openairframes") +MAX_RETRIES = 3 +RETRY_DELAY = 30 # seconds def main() -> None: @@ -28,12 +33,22 @@ def main() -> None: zip_path = OUT_ROOT / f"mictronics-db_{date_str}.zip" - print(f"Downloading {URL}...") - req = Request(URL, headers={"User-Agent": "openairframes-downloader/1.0"}, method="GET") - with urlopen(req, timeout=300) as r, zip_path.open("wb") as f: - shutil.copyfileobj(r, f) - - print(f"Wrote: {zip_path}") + for attempt in range(1, MAX_RETRIES + 1): + try: + print(f"Downloading {URL} (attempt {attempt}/{MAX_RETRIES})...") + req = Request(URL, headers={"User-Agent": "Mozilla/5.0 (compatible; openairframes-downloader/1.0)"}, method="GET") + with urlopen(req, timeout=120) as r, zip_path.open("wb") as f: + shutil.copyfileobj(r, f) + print(f"Wrote: {zip_path}") + return + except (URLError, TimeoutError) as e: + print(f"Attempt {attempt} failed: {e}") + if attempt < MAX_RETRIES: + print(f"Retrying in {RETRY_DELAY} seconds...") + time.sleep(RETRY_DELAY) + else: + print("All retries exhausted. Mictronics download failed.") + sys.exit(1) if __name__ == "__main__":