qbhf2 commited on
Commit
1d5744a
·
1 Parent(s): 04fcde9

modified: app.py

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