Spaces:
Sleeping
Sleeping
import os | |
import subprocess | |
import sys | |
import streamlit as st | |
process = None # Global variable to store process | |
def start_process(): | |
global process | |
if process is None or process.poll() is not None: # Check if process isn't running | |
process = subprocess.Popen([sys.executable, "-m", "Powers"]) | |
st.success(f"Process started with PID: {process.pid}") | |
else: | |
st.warning("The process is already running.") | |
def stop_process(): | |
global process | |
if process and process.poll() is None: # Check if process is running | |
process.terminate() # Stop process | |
process.wait() | |
st.success("Process stopped.") | |
else: | |
st.warning("The process is not running.") | |
def restart_process(): | |
stop_process() | |
start_process() | |
st.success("Process restarted.") | |
def main(): | |
st.title("Process Control Panel") | |
if not os.path.exists("Seonari"): | |
st.write("Cloning repository...") | |
subprocess.run(["git", "clone", "https://github.com/taslim19/Seonari"], check=True) | |
os.chdir("Seonari") | |
st.write("Installing dependencies...") | |
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True) | |
# Display buttons on the Streamlit app | |
if st.button("Start"): | |
start_process() | |
if st.button("Stop"): | |
stop_process() | |
if st.button("Restart"): | |
restart_process() | |
if __name__ == "__main__": | |
main() | |