sdd / app.py
cruiserein22's picture
Create app.py
1d3c6a9 verified
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()