Subir archivos a "/"
This commit is contained in:
commit
123773f578
100
picobuild.py
Normal file
100
picobuild.py
Normal file
@ -0,0 +1,100 @@
|
||||
import os
|
||||
import requests
|
||||
import zipfile
|
||||
from io import BytesIO
|
||||
import subprocess
|
||||
|
||||
def download_and_extract_latest_release():
|
||||
# GitHub API URL for repository releases
|
||||
repo_api_url = "https://api.github.com/repos/nixietab/pds/releases/latest"
|
||||
|
||||
try:
|
||||
# Get the latest release data
|
||||
response = requests.get(repo_api_url)
|
||||
response.raise_for_status()
|
||||
release_data = response.json()
|
||||
|
||||
# Find the PDS.zip asset in the release assets
|
||||
pds_zip_url = None
|
||||
for asset in release_data.get("assets", []):
|
||||
if asset["name"].lower() == "pds.zip":
|
||||
pds_zip_url = asset["browser_download_url"]
|
||||
break
|
||||
|
||||
if not pds_zip_url:
|
||||
print("Error: PDS.zip not found in the latest release.")
|
||||
return
|
||||
|
||||
# Download the PDS.zip file
|
||||
print(f"Downloading PDS.zip from {pds_zip_url}...")
|
||||
zip_response = requests.get(pds_zip_url)
|
||||
zip_response.raise_for_status()
|
||||
|
||||
# Extract the contents of the ZIP file
|
||||
with zipfile.ZipFile(BytesIO(zip_response.content)) as zip_file:
|
||||
process_folder = "progress"
|
||||
os.makedirs(process_folder, exist_ok=True)
|
||||
print(f"Extracting files to '{process_folder}'...")
|
||||
zip_file.extractall(process_folder)
|
||||
|
||||
print("Download and extraction complete.")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Network error: {e}")
|
||||
except zipfile.BadZipFile:
|
||||
print("Error: The downloaded file is not a valid ZIP file.")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
def clone_repository():
|
||||
repo_url = "https://github.com/nixietab/picodulce"
|
||||
progress_folder = "progress"
|
||||
|
||||
try:
|
||||
print(f"Cloning repository from {repo_url}...")
|
||||
if os.path.exists(progress_folder):
|
||||
print(f"Folder '{progress_folder}' already exists. Removing it...")
|
||||
subprocess.run(["rm", "-rf", progress_folder], check=True)
|
||||
subprocess.run(["git", "clone", repo_url, progress_folder], check=True)
|
||||
print(f"Repository cloned into '{progress_folder}'.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error during cloning: {e}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
def clone_root_repository():
|
||||
repo_url = "https://github.com/nixietab/2hsu"
|
||||
temp_folder = "temp_2hsu"
|
||||
|
||||
try:
|
||||
print(f"Cloning repository from {repo_url} into a temporary folder...")
|
||||
if os.path.exists(temp_folder):
|
||||
print(f"Folder '{temp_folder}' already exists. Removing it...")
|
||||
subprocess.run(["rm", "-rf", temp_folder], check=True)
|
||||
subprocess.run(["git", "clone", repo_url, temp_folder], check=True)
|
||||
print(f"Repository cloned into '{temp_folder}'.")
|
||||
|
||||
# Move contents to root folder
|
||||
for item in os.listdir(temp_folder):
|
||||
source = os.path.join(temp_folder, item)
|
||||
destination = os.path.join(".", item)
|
||||
if os.path.exists(destination):
|
||||
if os.path.isdir(destination):
|
||||
subprocess.run(["rm", "-rf", destination], check=True)
|
||||
else:
|
||||
os.remove(destination)
|
||||
os.rename(source, destination)
|
||||
|
||||
# Remove temporary folder
|
||||
subprocess.run(["rm", "-rf", temp_folder], check=True)
|
||||
print(f"Contents moved to root directory and temporary folder '{temp_folder}' removed.")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error during cloning: {e}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
download_and_extract_latest_release()
|
||||
clone_repository()
|
||||
clone_root_repository()
|
Loading…
Reference in New Issue
Block a user