From 57cbb9dde3ec8732b3b7d01ee1e9b978999d5eb1 Mon Sep 17 00:00:00 2001 From: gautam-404 Date: Wed, 20 Mar 2024 17:53:14 +1000 Subject: [PATCH] Update MESA download URLs and add optional text parameter in Download class --- mesaport/Installer/downloader.py | 5 ++++- mesaport/Installer/mesaurls.py | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mesaport/Installer/downloader.py b/mesaport/Installer/downloader.py index b429929..41c1375 100644 --- a/mesaport/Installer/downloader.py +++ b/mesaport/Installer/downloader.py @@ -18,6 +18,7 @@ def __init__(self, directory, version, ostype): Args: ver (str): Version of MESA to install. directory (str): Path to the directory where the MESA SDK and MESA zip files will be downloaded. + ostype (str): Operating system type. """ self.ostype = ostype self.directory = directory @@ -56,13 +57,15 @@ def check_n_download(self, filepath, url, text="Downloading..."): Args: filepath (str): Path to the file to be downloaded. url (str): URL of the file to be downloaded. + text (str, optional): Text to be displayed while downloading the file. Defaults to "Downloading...". """ headers = { "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0", } response = requests.get(url, headers=headers, stream=True) response.raise_for_status() - total = float(response.headers.get('content-length', 0)) + # total = float(response.headers.get('content-length', 0)) + total = float(response.headers.get('content-length', 0)) if response.headers.get('content-length') else 0 if os.path.exists(filepath) and total == os.path.getsize(filepath): print(text) print("[blue]File already downloaded. Skipping download.[/blue]\n") diff --git a/mesaport/Installer/mesaurls.py b/mesaport/Installer/mesaurls.py index f28361c..7e2caa0 100644 --- a/mesaport/Installer/mesaurls.py +++ b/mesaport/Installer/mesaurls.py @@ -2,13 +2,18 @@ mac_intel_versions = ["latest", "r23.05.1", "r22.11.1", "r22.05.1", "r21.12.1", "r15140", "r12778"] mac_arm_versions = ["latest", "r23.05.1", "r22.11.1", "r22.05.1"] -mesa_urls = {"latest": "https://github.com/MESAHub/mesa/archive/refs/tags/r24.03.1.zip", - "r24.03.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r24.03.1.zip", - "r23.05.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r23.05.1.zip", - "r22.11.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r22.11.1.zip", - "r22.05.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r22.05.1.zip", - "r21.12.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r21.12.1.zip", - "r15140": "https://github.com/MESAHub/mesa/archive/refs/tags/r15140.zip", +mesa_urls = {"latest": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r24.03.1", + "r24.03.1": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r24.03.1", + "r23.05.1": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r23.05.1", + "r22.11.1": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r22.11.1", + "r22.05.1": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r22.05.1", + "r21.12.1": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r21.12.1", + "r15140": "https://codeload.github.com/MESAHub/mesa/zip/refs/tags/r15140", + # "r23.05.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r23.05.1.zip", + # "r22.11.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r22.11.1.zip", + # "r22.05.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r22.05.1.zip", + # "r21.12.1": "https://github.com/MESAHub/mesa/archive/refs/tags/r21.12.1.zip", + # "r15140": "https://github.com/MESAHub/mesa/archive/refs/tags/r15140.zip", "r12778": "https://zenodo.org/record/7319739/files/mesa-r12778.zip"}