Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,19 +1,33 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
import os
|
| 3 |
import time
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
#subprocess.call(["pip", "install", "flet_fastapi==0.19.0"])
|
| 7 |
-
|
| 8 |
gh_token = os.getenv("gh_token")
|
| 9 |
|
|
|
|
| 10 |
url_with_token = f"https://{gh_token}@github.com/Eslam-Magdy-1297/Adel_Flet_Demo.git"
|
| 11 |
|
|
|
|
| 12 |
os.system(f"git clone {url_with_token}")
|
| 13 |
|
|
|
|
| 14 |
time.sleep(10)
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
code = file.read()
|
| 18 |
exec(code)
|
| 19 |
-
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
+
import shutil
|
| 4 |
|
| 5 |
+
# Get GitHub token from environment variables
|
|
|
|
|
|
|
| 6 |
gh_token = os.getenv("gh_token")
|
| 7 |
|
| 8 |
+
# URL with token for private repo access
|
| 9 |
url_with_token = f"https://{gh_token}@github.com/Eslam-Magdy-1297/Adel_Flet_Demo.git"
|
| 10 |
|
| 11 |
+
# Clone the GitHub repository
|
| 12 |
os.system(f"git clone {url_with_token}")
|
| 13 |
|
| 14 |
+
# Sleep to ensure the clone operation is complete
|
| 15 |
time.sleep(10)
|
| 16 |
|
| 17 |
+
# Define the source and destination directories
|
| 18 |
+
source_dir = "Adel_Flet_Demo"
|
| 19 |
+
destination_dir = "."
|
| 20 |
+
|
| 21 |
+
# Move the contents of the Adel_Flet_Demo directory to the current directory
|
| 22 |
+
for item in os.listdir(source_dir):
|
| 23 |
+
s = os.path.join(source_dir, item)
|
| 24 |
+
d = os.path.join(destination_dir, item)
|
| 25 |
+
shutil.move(s, d)
|
| 26 |
+
|
| 27 |
+
# Remove the now empty Adel_Flet_Demo directory
|
| 28 |
+
os.rmdir(source_dir)
|
| 29 |
+
|
| 30 |
+
# Read and execute the main.py file
|
| 31 |
+
with open("main.py", "r") as file:
|
| 32 |
code = file.read()
|
| 33 |
exec(code)
|
|
|