MCPcopy Create free account
hub / github.com/apache/solr / download_file

Function download_file

dev-tools/scripts/refguide/refguide-download-js-css.py:44–60  ·  view source on GitHub ↗

Download a file from a URL to a local path.

(url, dest_path)

Source from the content-addressed store, hash-verified

42 return url.startswith("http://") or url.startswith("https://") or url.startswith("//")
43
44def download_file(url, dest_path):
45 """Download a file from a URL to a local path."""
46 if os.path.exists(dest_path):
47 #print(f"Skipping {url} (already downloaded to {dest_path})")
48 return
49 try:
50 if url.startswith("//"):
51 url = "https:" + url # Default to HTTPS for protocol-relative URLs
52 if url.startswith("https://oss.maxcdn.com/"):
53 url = url.replace("https://oss.maxcdn.com/", "https://cdnjs.cloudflare.com/ajax/")
54 response = requests.get(url, timeout=10)
55 response.raise_for_status()
56 with open(dest_path, "wb") as f:
57 f.write(response.content)
58 print(f"Downloaded {url} to {dest_path}")
59 except Exception as e:
60 print(f"Failed to download {url}: {e}")
61
62def add_version_to_filename(filename, version):
63 """Add version number to filename if not already present.

Callers 1

process_html_fileFunction · 0.85

Calls 4

existsMethod · 0.65
getMethod · 0.65
writeMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…