Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -1,33 +1,35 @@
|
|
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)
|
|
|
1 |
import os
|
2 |
import time
|
3 |
import shutil
|
4 |
+
import subprocess
|
5 |
+
|
6 |
+
command = ["pip", "install", "flet==0.23.2"]
|
7 |
+
|
8 |
+
subprocess.run(command, check=True)
|
9 |
+
|
10 |
+
command = ["pip", "install", "flet-fastapi", "--no-deps"]
|
11 |
+
|
12 |
+
subprocess.run(command, check=True)
|
13 |
+
|
14 |
|
|
|
15 |
gh_token = os.getenv("gh_token")
|
16 |
|
|
|
17 |
url_with_token = f"https://{gh_token}@github.com/Eslam-Magdy-1297/Adel_Flet_Demo.git"
|
18 |
|
|
|
19 |
os.system(f"git clone {url_with_token}")
|
20 |
|
|
|
21 |
time.sleep(10)
|
22 |
|
|
|
23 |
source_dir = "Adel_Flet_Demo"
|
24 |
destination_dir = "."
|
25 |
|
|
|
26 |
for item in os.listdir(source_dir):
|
27 |
s = os.path.join(source_dir, item)
|
28 |
d = os.path.join(destination_dir, item)
|
29 |
shutil.move(s, d)
|
30 |
|
|
|
31 |
os.rmdir(source_dir)
|
32 |
|
|
|
33 |
with open("main.py", "r") as file:
|
34 |
code = file.read()
|
35 |
exec(code)
|