Spaces:
Running
Running
File size: 1,634 Bytes
1d3c6a9 |
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 |
cp -r C:/Users/Admin/Downloads/sd/* C:/Users/Admin/Downloads/sdd /
import os
import subprocess
# Define the GitHub repository URL
GITHUB_REPO = "https://github.com/cruiserein22/sd.git"
REPO_DIR = "sd" # Local directory to clone the repo
def clone_or_pull_repo():
# Check if the repo directory already exists
if os.path.exists(REPO_DIR):
# Pull the latest changes if the repo already exists
print("Pulling latest changes...")
subprocess.run(["git", "-C", REPO_DIR, "pull"], check=True)
else:
# Clone the repository if it doesn't exist
print("Cloning repository...")
subprocess.run(["git", "clone", GITHUB_REPO, REPO_DIR], check=True)
def install_requirements():
# Install dependencies from requirements_versions.txt
requirements_path = os.path.join(REPO_DIR, "requirements_versions.txt")
if os.path.exists(requirements_path):
print("Installing requirements...")
subprocess.run(["pip", "install", "-r", requirements_path], check=True)
else:
print("requirements_versions.txt not found!")
def launch_application():
# Run launch.py with --api
launch_script = os.path.join(REPO_DIR, "launch.py")
if os.path.exists(launch_script):
print("Launching the application...")
subprocess.run(["python", launch_script, "--api"], check=True)
else:
print("launch.py not found!")
def main():
# Ensure the repository is up-to-date
clone_or_pull_repo()
# Install dependencies
install_requirements()
# Launch the application
launch_application()
if __name__ == "__main__":
main()
|