GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — junkcode/python/fetch_cygwin_build.py at master · tridge/junkcode Expand file tree/ Copy pathfetch_cygwin_build.pyMore file actions executable file ·126 lines (105 loc) · 4.08 KB / Copy pathfetch_cygwin_build.pyFile metadata and controlsexecutable file ·126 lines (105 loc) · 4.08 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 #!/usr/bin/env python3 """ Download binaries.zip artifact from the Cygwin Build workflow for a specified branch of github.com/ArduPilot/ardupilot. Requires a GitHub token (public repo read-only is sufficient), set via: - GITHUB_TOKEN environment variable, or - ~/.config/fetch_cygwin_token (single line with token), or - ~/.config/gh/hosts.yml (gh CLI config) Usage: ./fetch_cygwin_build.py ArduPilot-4.7 ./fetch_cygwin_build.py master ./fetch_cygwin_build.py ArduPilot-4.7 -o /tmp/binaries.zip """ import argparse import sys import os try: import requests except ImportError: print("Error: 'requests' module required. Install with: pip3 install requests", file=sys.stderr) sys.exit(1) API = "https://api.github.com" REPO = "ArduPilot/ardupilot" WORKFLOW_ID = 8391275 # Cygwin Build def get_token(): """Get GitHub token from environment or gh CLI config.""" token = os.environ.get("GITHUB_TOKEN") if token: return token # Try dedicated token file token_file = os.path.expanduser("~/.config/fetch_cygwin_token") if os.path.exists(token_file): with open(token_file) as f: token = f.read().strip() if token: return token # Try gh CLI config (simple YAML parse without yaml module) gh_hosts = os.path.expanduser("~/.config/gh/hosts.yml") if os.path.exists(gh_hosts): with open(gh_hosts) as f: for line in f: line = line.strip() if line.startswith("oauth_token:"): token = line.split(":", 1)[1].strip() if token: return token print("Error: No GitHub token found.", file=sys.stderr) print("Set GITHUB_TOKEN, or create ~/.config/fetch_cygwin_token", file=sys.stderr) sys.exit(1) def main(): parser = argparse.ArgumentParser(description="Download Cygwin Build binaries.zip for a branch") parser.add_argument("branch", help="Branch name (e.g. ArduPilot-4.7, master)") parser.add_argument("-o", "--output", default="binaries.zip", help="Output filename (default: binaries.zip)") args = parser.parse_args() token = get_token() headers = { "Authorization": f"token {token}", "Accept": "application/vnd.github+json", } # Find the latest successful Cygwin Build run for this branch print(f"Finding latest Cygwin Build for branch '{args.branch}'...") r = requests.get( f"{API}/repos/{REPO}/actions/workflows/{WORKFLOW_ID}/runs", headers=headers, params={"branch": args.branch, "status": "success", "per_page": 1}, ) r.raise_for_status() data = r.json() if not data.get("workflow_runs"): print(f"No successful Cygwin Build runs found for branch '{args.branch}'", file=sys.stderr) sys.exit(1) run = data["workflow_runs"][0] run_id = run["id"] print(f"Found run #{run['run_number']} ({run['created_at']}) - {run['html_url']}") # Find the binaries artifact r = requests.get(f"{API}/repos/{REPO}/actions/runs/{run_id}/artifacts", headers=headers) r.raise_for_status() binaries = None for a in r.json().get("artifacts", []): if a["name"] == "binaries": binaries = a break if not binaries: print("No 'binaries' artifact found in this run", file=sys.stderr) sys.exit(1) if binaries.get("expired"): print("Artifact has expired and is no longer available", file=sys.stderr) sys.exit(1) size_mb = binaries["size_in_bytes"] / (1024 * 1024) print(f"Downloading binaries ({size_mb:.1f} MB)...") # Download the artifact zip r = requests.get( f"{API}/repos/{REPO}/actions/artifacts/{binaries['id']}/zip", headers=headers, stream=True, allow_redirects=True, ) r.raise_for_status() with open(args.output, "wb") as f: for chunk in r.iter_content(chunk_size=65536): f.write(chunk) actual_size = os.path.getsize(args.output) print(f"Saved to {args.output} ({actual_size / (1024*1024):.1f} MB)") if __name__ == "__main__": main() |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |