Spaces:
Sleeping
Sleeping
update
Browse files
init.py
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
st.set_page_config(
|
| 7 |
+
page_title="Vnstock - Giải pháp phân tích chứng khoán toàn diện",
|
| 8 |
+
page_icon="📊",
|
| 9 |
+
layout="wide",
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
secure_repo = st.secrets["private_repo"]
|
| 13 |
+
git_user = st.secrets["git_usr"]
|
| 14 |
+
git_token = st.secrets["git_token"]
|
| 15 |
+
|
| 16 |
+
def core_engine_setup():
|
| 17 |
+
repo_url = "https://<user>:<token>@github.com/<user>/<repo>.git"
|
| 18 |
+
# Replace <token> with the environment variable for your GitHub PAT
|
| 19 |
+
secure_url = repo_url.replace("<token>", git_token).replace("<user>", git_user).replace("<repo>", secure_repo)
|
| 20 |
+
# subprocess.run(f"pip install git+{secure_url}", shell=True, check=True)
|
| 21 |
+
if not os.path.isdir(secure_repo):
|
| 22 |
+
subprocess.run(["git", "clone", secure_url], check=True)
|
| 23 |
+
os.chdir("{secure_repo}/streamlit_space/private_app")
|
| 24 |
+
|
| 25 |
+
try:
|
| 26 |
+
# subprocess.run(f"ls -l", shell=True, check=True)
|
| 27 |
+
if not os.path.isfile("requirements_installed.txt"):
|
| 28 |
+
core_engine_setup()
|
| 29 |
+
print('The core engine initialized successfully!')
|
| 30 |
+
subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True)
|
| 31 |
+
# Create a file indicating requirements have been installed
|
| 32 |
+
with open("requirements_installed.txt", "w") as f:
|
| 33 |
+
f.write("Requirements installed.")
|
| 34 |
+
|
| 35 |
+
# from datetime import datetime, timedelta
|
| 36 |
+
import main
|
| 37 |
+
main.render()
|
| 38 |
+
|
| 39 |
+
except Exception as e:
|
| 40 |
+
st.warning('Something went wrong! Please try again!')
|
| 41 |
+
print(f'Error details: {e}')
|