mirror of
https://github.com/johndoe6345789/bamboogenerator.git
synced 2026-04-24 13:24:54 +00:00
Merge pull request #3 from Rich43/codex/fix-openscad-installer-url-handling
Fix OpenSCAD installer URL handling
This commit is contained in:
@@ -1,39 +1,40 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
import requests
|
||||
|
||||
logging.basicConfig(filename='install_debug.log', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def download_openscad():
|
||||
try:
|
||||
with open('openscad_download_url.txt', 'r') as f:
|
||||
url = f.read().strip()
|
||||
except FileNotFoundError:
|
||||
logging.error("openscad_download_url.txt not found! Please run scrape_openscad_download.py first.")
|
||||
print("openscad_download_url.txt not found! Please run scrape_openscad_download.py first to get the latest URL.")
|
||||
sys.exit(1)
|
||||
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Attempting to download OpenSCAD from {url}")
|
||||
print("Downloading OpenSCAD installer...")
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
response.raise_for_status()
|
||||
logging.info(f"Download started for {url}")
|
||||
with open(installer, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
logging.info(f"Download completed, saved as {installer}")
|
||||
print("Download completed.")
|
||||
return True
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Download failed: {e}")
|
||||
print(f"Failed to download OpenSCAD installer: {e}")
|
||||
return False
|
||||
def download_openscad():
|
||||
try:
|
||||
with open('openscad_download_url.txt', 'r') as f:
|
||||
url = f.read().strip()
|
||||
except FileNotFoundError:
|
||||
logging.error("openscad_download_url.txt not found! Please run scrape_openscad_download.py first.")
|
||||
print("openscad_download_url.txt not found! Please run scrape_openscad_download.py first to get the latest URL.")
|
||||
sys.exit(1)
|
||||
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Attempting to download OpenSCAD from {url}")
|
||||
print("Downloading OpenSCAD installer...")
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
response.raise_for_status()
|
||||
logging.info(f"Download started for {url}")
|
||||
with open(installer, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
logging.info(f"Download completed, saved as {installer}")
|
||||
print("Download completed.")
|
||||
return url
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Download failed: {e}")
|
||||
print(f"Failed to download OpenSCAD installer: {e}")
|
||||
return None
|
||||
|
||||
def install_openscad():
|
||||
installer = os.path.basename(url) # Use the same name as downloaded
|
||||
def install_openscad(url):
|
||||
installer = os.path.basename(url) # Use the same name as downloaded
|
||||
logging.debug(f"Checking if installer exists at {installer}")
|
||||
if not os.path.exists(installer):
|
||||
logging.warning("Installer not found after download attempt")
|
||||
@@ -52,23 +53,23 @@ def install_openscad():
|
||||
print(f"Installation failed: {e}")
|
||||
return False
|
||||
|
||||
def cleanup():
|
||||
installer = os.path.basename(url)
|
||||
def cleanup(url):
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Checking for cleanup of {installer}")
|
||||
if os.path.exists(installer):
|
||||
os.remove(installer)
|
||||
logging.info(f"Cleaned up installer file {installer}")
|
||||
print("Cleaned up installer file.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import requests # Import here to avoid circular dependency issues
|
||||
logging.debug("Starting install_openscad.py execution")
|
||||
if not download_openscad():
|
||||
sys.exit(1)
|
||||
if not install_openscad():
|
||||
cleanup()
|
||||
sys.exit(1)
|
||||
cleanup()
|
||||
if __name__ == "__main__":
|
||||
logging.debug("Starting install_openscad.py execution")
|
||||
url = download_openscad()
|
||||
if not url:
|
||||
sys.exit(1)
|
||||
if not install_openscad(url):
|
||||
cleanup(url)
|
||||
sys.exit(1)
|
||||
cleanup(url)
|
||||
logging.info("OpenSCAD installation process completed")
|
||||
print("Please ensure OpenSCAD is added to your system PATH.")
|
||||
print("You may need to restart your command prompt or system for changes to take effect.")
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
import requests
|
||||
|
||||
logging.basicConfig(filename='install_debug.log', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def download_openscad():
|
||||
try:
|
||||
with open('openscad_download_url.txt', 'r') as f:
|
||||
url = f.read().strip()
|
||||
except FileNotFoundError:
|
||||
logging.error("openscad_download_url.txt not found! Please run scrape_openscad_download.py first.")
|
||||
print("openscad_download_url.txt not found! Please run scrape_openscad_download.py first to get the latest URL.")
|
||||
sys.exit(1)
|
||||
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Attempting to download OpenSCAD from {url}")
|
||||
print("Downloading OpenSCAD installer...")
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
response.raise_for_status()
|
||||
logging.info(f"Download started for {url}")
|
||||
with open(installer, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
logging.info(f"Download completed, saved as {installer}")
|
||||
print("Download completed.")
|
||||
return True
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Download failed: {e}")
|
||||
print(f"Failed to download OpenSCAD installer: {e}")
|
||||
return False
|
||||
def download_openscad():
|
||||
try:
|
||||
with open('openscad_download_url.txt', 'r') as f:
|
||||
url = f.read().strip()
|
||||
except FileNotFoundError:
|
||||
logging.error("openscad_download_url.txt not found! Please run scrape_openscad_download.py first.")
|
||||
print("openscad_download_url.txt not found! Please run scrape_openscad_download.py first to get the latest URL.")
|
||||
sys.exit(1)
|
||||
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Attempting to download OpenSCAD from {url}")
|
||||
print("Downloading OpenSCAD installer...")
|
||||
try:
|
||||
response = requests.get(url, stream=True)
|
||||
response.raise_for_status()
|
||||
logging.info(f"Download started for {url}")
|
||||
with open(installer, 'wb') as f:
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
logging.info(f"Download completed, saved as {installer}")
|
||||
print("Download completed.")
|
||||
return url
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Download failed: {e}")
|
||||
print(f"Failed to download OpenSCAD installer: {e}")
|
||||
return None
|
||||
|
||||
def install_openscad():
|
||||
installer = os.path.basename(url) # Use the same name as downloaded
|
||||
def install_openscad(url):
|
||||
installer = os.path.basename(url) # Use the same name as downloaded
|
||||
logging.debug(f"Checking if installer exists at {installer}")
|
||||
if not os.path.exists(installer):
|
||||
logging.warning("Installer not found after download attempt")
|
||||
@@ -52,23 +53,23 @@ def install_openscad():
|
||||
print(f"Installation failed: {e}")
|
||||
return False
|
||||
|
||||
def cleanup():
|
||||
installer = os.path.basename(url)
|
||||
def cleanup(url):
|
||||
installer = os.path.basename(url)
|
||||
logging.debug(f"Checking for cleanup of {installer}")
|
||||
if os.path.exists(installer):
|
||||
os.remove(installer)
|
||||
logging.info(f"Cleaned up installer file {installer}")
|
||||
print("Cleaned up installer file.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import requests # Import here to avoid circular dependency issues
|
||||
logging.debug("Starting install_openscad.py execution")
|
||||
if not download_openscad():
|
||||
sys.exit(1)
|
||||
if not install_openscad():
|
||||
cleanup()
|
||||
sys.exit(1)
|
||||
cleanup()
|
||||
if __name__ == "__main__":
|
||||
logging.debug("Starting install_openscad.py execution")
|
||||
url = download_openscad()
|
||||
if not url:
|
||||
sys.exit(1)
|
||||
if not install_openscad(url):
|
||||
cleanup(url)
|
||||
sys.exit(1)
|
||||
cleanup(url)
|
||||
logging.info("OpenSCAD installation process completed")
|
||||
print("Please ensure OpenSCAD is added to your system PATH.")
|
||||
print("You may need to restart your command prompt or system for changes to take effect.")
|
||||
|
||||
Reference in New Issue
Block a user