57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
import subprocess
|
|
import os
|
|
import sys
|
|
import time
|
|
import webbrowser
|
|
|
|
|
|
def install_missing_packages():
|
|
packages = ["uvicorn", "fastapi", "sentence-transformers"]
|
|
for package in packages:
|
|
try:
|
|
__import__(package.replace("-", "_"))
|
|
except ImportError:
|
|
print(f"[*] Instalowanie brakującej biblioteki: {package}...")
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
|
|
|
|
|
def run_archivium():
|
|
install_missing_packages()
|
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
backend_script = os.path.join(base_dir, "Database", "database.py")
|
|
frontend_dir = os.path.join(base_dir, "TextEditor")
|
|
|
|
print("\n--- URUCHAMIANIE SYSTEMU ARCHIVIUM ---")
|
|
|
|
print(f"[*] Startuję bazę danych...")
|
|
backend_process = subprocess.Popen(
|
|
[sys.executable, backend_script],
|
|
cwd=os.path.join(base_dir, "Database")
|
|
)
|
|
|
|
print(f"[*] Startuję edytor...")
|
|
frontend_process = subprocess.Popen(
|
|
"npm start",
|
|
shell=True,
|
|
cwd=frontend_dir,
|
|
creationflags=subprocess.CREATE_NEW_CONSOLE
|
|
)
|
|
|
|
print("[*] Oczekiwanie na gotowość...")
|
|
time.sleep(5)
|
|
|
|
webbrowser.open("http://localhost:3000")
|
|
|
|
try:
|
|
backend_process.wait()
|
|
frontend_process.wait()
|
|
except KeyboardInterrupt:
|
|
print("\n[*] Zamykanie systemu...")
|
|
backend_process.terminate()
|
|
frontend_process.terminate()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_archivium()
|