Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import time
|
| 3 |
+
import shutil
|
| 4 |
+
import subprocess
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
gh_token = os.getenv("gh_token")
|
| 10 |
+
|
| 11 |
+
url_with_token = f"https://{gh_token}@github.com/FaridaYasserYoussef/arabHistoriographyFastAPI"
|
| 12 |
+
|
| 13 |
+
os.system(f"git clone {url_with_token}")
|
| 14 |
+
|
| 15 |
+
time.sleep(10)
|
| 16 |
+
|
| 17 |
+
source_dir = "arabHistoriographyFastAPI"
|
| 18 |
+
destination_dir = "."
|
| 19 |
+
|
| 20 |
+
for item in os.listdir(source_dir):
|
| 21 |
+
s = os.path.join(source_dir, item)
|
| 22 |
+
d = os.path.join(destination_dir, item)
|
| 23 |
+
shutil.move(s, d)
|
| 24 |
+
|
| 25 |
+
os.rmdir(source_dir)
|
| 26 |
+
|
| 27 |
+
with open("requirements.txt", "r", encoding="utf-16") as file:
|
| 28 |
+
lines = file.readlines()
|
| 29 |
+
|
| 30 |
+
with open("requirements.txt", "w", encoding="utf-16") as file:
|
| 31 |
+
for line in lines:
|
| 32 |
+
if "numpy==2.1.2" in line:
|
| 33 |
+
file.write(line.replace("2.1.2", "2.0.2"))
|
| 34 |
+
else:
|
| 35 |
+
file.write(line)
|
| 36 |
+
|
| 37 |
+
command = ["pip", "install", "-r", "requirements.txt"]
|
| 38 |
+
|
| 39 |
+
subprocess.run(command, check=True)
|
| 40 |
+
|
| 41 |
+
with open("main.py", "r") as file:
|
| 42 |
+
code = file.read()
|
| 43 |
+
exec(code)
|