vnstock / init.py
thinh-vu's picture
Update init.py
70981f4 verified
raw
history blame contribute delete
No virus
1.47 kB
import streamlit as st
import os
import subprocess
import sys
st.set_page_config(
page_title="Vnstock - Giải pháp phân tích chứng khoán toàn diện",
page_icon="📊",
layout="wide",
)
secure_repo = st.secrets["private_repo"]
git_user = st.secrets["git_usr"]
git_token = st.secrets["MCGtk"]
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(secure_repo)
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}')