qbhf2 commited on
Commit
5eb1bcc
·
verified ·
1 Parent(s): 129a798

Create setup_env.py

Browse files
Files changed (1) hide show
  1. custom_utils/setup_env.py +22 -0
custom_utils/setup_env.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+
4
+ # Запуск setup.sh для настройки окружения и source ~/.bashrc
5
+ def run_setup_script():
6
+ setup_script_path = os.path.join(os.path.dirname(__file__), "startup.sh")
7
+ try:
8
+ print("Running setup script...")
9
+ # Выполнить setup.sh и source ~/.bashrc в одной сессии bash
10
+ subprocess.run(
11
+ f"bash -c 'source ~/.bashrc && bash {setup_script_path}'",
12
+ shell=True,
13
+ check=True,
14
+ )
15
+ print("Setup script and environment initialization completed successfully!")
16
+ except subprocess.CalledProcessError as e:
17
+ print(f"Error while running setup script or sourcing .bashrc: {e}")
18
+ exit(1)
19
+
20
+ # Выполнить setup.sh перед запуском приложения
21
+ if __name__="__main__":
22
+ run_setup_script()