Clone
5
Home
Shawn edited this page 2026-05-21 18:55:51 -04:00

Cantaloupe Downloader

Automation for exporting machine data from mycantaloupe.com.

Repo: shawn/cantaloupe-downloader Local: ~/projects/cantaloupe-downloader/ Latest commit: e408867

Purpose

CLI tool to authenticate with mycantaloupe.com and download the Machine List Excel export via direct HTTP (httpx) — no browser automation needed. Built-in diff tracking compares exports across runs.

Architecture

  • src/auth.py — ASP.NET FormsAuth login (CSRF token + session cookies via httpx)
  • src/download.py — Export download automation
    • Authenticate → verify access → POST /cs4/VueMachineList/ExcelExport → save .xlsx
  • cantaloupe/ — Click CLI wrapper (python -m cantaloupe export)
    • cantaloupe/cli.py — export + diff + configure commands
    • cantaloupe/config.py — credential management (~/.cantaloupe.env)
    • cantaloupe/diff.py — diff engine comparing xlsx by Asset ID, manifest tracking

Quick Start

cd ~/projects/cantaloupe-downloader
pip install -r requirements.txt

# Option 1: Save credentials to ~/.cantaloupe.env
python -m cantaloupe configure

# Option 2: Set environment variables
export CANTALOUPE_EMAIL="your@email.com"
export CANTALOUPE_PASSWORD="your-password"

# Download export
python -m cantaloupe export --output ./exports/

# Download + auto-compare with previous export
python -m cantaloupe export --diff

# Compare two exports
python -m cantaloupe diff --from old.xlsx --to new.xlsx

# Cron/scheduled mode
python -m cantaloupe export --scheduled --output /data/exports/

CLI Commands

Command Description
python -m cantaloupe export Download machine list Excel
python -m cantaloupe diff Compare two exports and show changes
python -m cantaloupe configure Save credentials to ~/.cantaloupe.env

Export Options

Flag Description
-o, --output PATH Output directory or file path
--headless / --visible Browser mode for Playwright fallback
--scheduled Non-interactive cron mode
--diff / --no-diff Auto-compare with previous export after download
--email TEXT Override account email
--password TEXT Override account password

Diff Options

Flag Description
--from PATH Older xlsx file (default: auto from manifest)
--to PATH Newer xlsx file (default: auto from manifest)
--id-column NAME Column to use as unique key (auto-detected)
--json Output machine-readable JSON

Diff Tracking

Compares two Excel exports keyed on Asset ID (auto-detected, case-insensitive). Reports:

  • 🟢 New machines added
  • 🔴 Machines removed
  • 🟡 Machines with changed fields

Manifest at ~/.cantaloupe-exports/manifest.json tracks export history for auto-diff.

Credential Priority

  1. CANTALOUPE_EMAIL / CANTALOUPE_PASSWORD environment variables
  2. ~/.cantaloupe.env file (created by configure command)
  3. Interactive prompt (unless --scheduled)

API Details

See API Investigation for full endpoint documentation.

  • Auth: POST /login/api/SignIn/SignIn/en-US with CSRF token
  • Export: POST /cs4/VueMachineList/ExcelExport → .xlsx (60+ columns)
  • Cookies: ASP.NET_SessionId, ApplicationGatewayAffinity, AeonPrincipalCacheVersion

Test Status

130 tests passing (27 auth + 20 download + 39 CLI + 44 diff) as of commit e408867.

Environment Variables

Variable Required Description
CANTALOUPE_EMAIL Yes mycantaloupe.com login email
CANTALOUPE_PASSWORD Yes mycantaloupe.com login password

Credentials can also be stored in ~/.cantaloupe.env via python -m cantaloupe configure.