Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cp -r C:/Users/Admin/Downloads/sd/* C:/Users/Admin/Downloads/sdd /
|
2 |
+
|
3 |
+
import os
|
4 |
+
import subprocess
|
5 |
+
|
6 |
+
# Define the GitHub repository URL
|
7 |
+
GITHUB_REPO = "https://github.com/cruiserein22/sd.git"
|
8 |
+
REPO_DIR = "sd" # Local directory to clone the repo
|
9 |
+
|
10 |
+
def clone_or_pull_repo():
|
11 |
+
# Check if the repo directory already exists
|
12 |
+
if os.path.exists(REPO_DIR):
|
13 |
+
# Pull the latest changes if the repo already exists
|
14 |
+
print("Pulling latest changes...")
|
15 |
+
subprocess.run(["git", "-C", REPO_DIR, "pull"], check=True)
|
16 |
+
else:
|
17 |
+
# Clone the repository if it doesn't exist
|
18 |
+
print("Cloning repository...")
|
19 |
+
subprocess.run(["git", "clone", GITHUB_REPO, REPO_DIR], check=True)
|
20 |
+
|
21 |
+
def install_requirements():
|
22 |
+
# Install dependencies from requirements_versions.txt
|
23 |
+
requirements_path = os.path.join(REPO_DIR, "requirements_versions.txt")
|
24 |
+
if os.path.exists(requirements_path):
|
25 |
+
print("Installing requirements...")
|
26 |
+
subprocess.run(["pip", "install", "-r", requirements_path], check=True)
|
27 |
+
else:
|
28 |
+
print("requirements_versions.txt not found!")
|
29 |
+
|
30 |
+
def launch_application():
|
31 |
+
# Run launch.py with --api
|
32 |
+
launch_script = os.path.join(REPO_DIR, "launch.py")
|
33 |
+
if os.path.exists(launch_script):
|
34 |
+
print("Launching the application...")
|
35 |
+
subprocess.run(["python", launch_script, "--api"], check=True)
|
36 |
+
else:
|
37 |
+
print("launch.py not found!")
|
38 |
+
|
39 |
+
def main():
|
40 |
+
# Ensure the repository is up-to-date
|
41 |
+
clone_or_pull_repo()
|
42 |
+
# Install dependencies
|
43 |
+
install_requirements()
|
44 |
+
# Launch the application
|
45 |
+
launch_application()
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
+
main()
|