xdragxt commited on
Commit
0bee3d6
·
1 Parent(s): 02dde9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -1,56 +1,57 @@
1
  import os
2
  import subprocess
3
  import sys
4
- import tkinter as tk
5
- from tkinter import messagebox
6
 
7
- process = None # Store the running process
8
 
9
 
10
  def start_process():
11
  global process
12
  if process is None or process.poll() is not None: # Check if process isn't running
13
  process = subprocess.Popen([sys.executable, "-m", "Powers"])
14
- messagebox.showinfo("Start", f"Process started with PID: {process.pid}")
15
  else:
16
- messagebox.showinfo("Already Running", "The process is already running.")
17
 
18
 
19
  def stop_process():
20
  global process
21
  if process and process.poll() is None: # Check if process is running
22
- process.terminate() # Graceful stop
23
  process.wait()
24
- messagebox.showinfo("Stop", "Process stopped.")
25
  else:
26
- messagebox.showinfo("Not Running", "The process is not running.")
27
 
28
 
29
  def restart_process():
30
  stop_process()
31
  start_process()
32
- messagebox.showinfo("Restart", "Process restarted.")
33
 
34
 
35
  def main():
36
- # Clone the repository and install dependencies if needed
 
37
  if not os.path.exists("Seonari"):
 
38
  subprocess.run(["git", "clone", "https://github.com/taslim19/Seonari"], check=True)
39
-
40
  os.chdir("Seonari")
 
 
41
  subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
42
 
43
- # Create the GUI
44
- root = tk.Tk()
45
- root.title("Process Control")
46
 
47
- # Create buttons
48
- tk.Button(root, text="Start", command=start_process, width=15, height=2).pack(pady=10)
49
- tk.Button(root, text="Stop", command=stop_process, width=15, height=2).pack(pady=10)
50
- tk.Button(root, text="Restart", command=restart_process, width=15, height=2).pack(pady=10)
51
- tk.Button(root, text="Exit", command=root.quit, width=15, height=2).pack(pady=10)
52
 
53
- root.mainloop() # Run the GUI loop
 
54
 
55
 
56
  if __name__ == "__main__":
 
1
  import os
2
  import subprocess
3
  import sys
4
+ import streamlit as st
 
5
 
6
+ process = None # Global variable to store process
7
 
8
 
9
  def start_process():
10
  global process
11
  if process is None or process.poll() is not None: # Check if process isn't running
12
  process = subprocess.Popen([sys.executable, "-m", "Powers"])
13
+ st.success(f"Process started with PID: {process.pid}")
14
  else:
15
+ st.warning("The process is already running.")
16
 
17
 
18
  def stop_process():
19
  global process
20
  if process and process.poll() is None: # Check if process is running
21
+ process.terminate() # Stop process
22
  process.wait()
23
+ st.success("Process stopped.")
24
  else:
25
+ st.warning("The process is not running.")
26
 
27
 
28
  def restart_process():
29
  stop_process()
30
  start_process()
31
+ st.success("Process restarted.")
32
 
33
 
34
  def main():
35
+ st.title("Process Control Panel")
36
+
37
  if not os.path.exists("Seonari"):
38
+ st.write("Cloning repository...")
39
  subprocess.run(["git", "clone", "https://github.com/taslim19/Seonari"], check=True)
40
+
41
  os.chdir("Seonari")
42
+
43
+ st.write("Installing dependencies...")
44
  subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
45
 
46
+ # Display buttons on the Streamlit app
47
+ if st.button("Start"):
48
+ start_process()
49
 
50
+ if st.button("Stop"):
51
+ stop_process()
 
 
 
52
 
53
+ if st.button("Restart"):
54
+ restart_process()
55
 
56
 
57
  if __name__ == "__main__":