Spaces:
Sleeping
Sleeping
import streamlit as st | |
import os | |
import subprocess | |
import sys | |
secure_repo = st.secrets["private_repo"] | |
git_user = st.secrets["git_usr"] | |
git_token = st.secrets["git_token"] | |
def core_engine_setup(): | |
repo_url = "https://<user>:<token>@github.com/<user>/<repo>.git" | |
# Replace <token> with the environment variable for your GitHub PAT | |
secure_url = repo_url.replace("<token>", git_token).replace("<user>", git_user).replace("<repo>", secure_repo) | |
# subprocess.run(f"pip install git+{secure_url}", shell=True, check=True) | |
if not os.path.isdir(secure_repo): | |
subprocess.run(["git", "clone", secure_url], check=True) | |
os.chdir(f"{secure_repo}/streamlit_space/private_app") | |
try: | |
# subprocess.run(f"ls -l", shell=True, check=True) | |
if not os.path.isfile("requirements_installed.txt"): | |
core_engine_setup() | |
print('The core engine initialized successfully!') | |
subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True) | |
# Create a file indicating requirements have been installed | |
with open("requirements_installed.txt", "w") as f: | |
f.write("Requirements installed.") | |
# from datetime import datetime, timedelta | |
import main | |
main.render() | |
except Exception as e: | |
st.warning('Something went wrong! Please try again!') | |
print(f'Error details: {e}') |