admin commited on
Commit
00a5428
·
1 Parent(s): d4fa759

add status

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -3,24 +3,31 @@ import gradio as gr
3
 
4
 
5
  def infer(command):
 
 
6
  try:
7
- return subprocess.check_output(
8
  command,
9
  shell=True,
10
  stderr=subprocess.STDOUT,
11
  text=True,
12
  )
13
 
14
- except subprocess.CalledProcessError as e:
15
- return f"Error: {e.output}"
 
 
16
 
17
 
18
  if __name__ == "__main__":
19
  gr.Interface(
20
  fn=infer,
21
  inputs=gr.Textbox(label="Linux Command", value="ls"),
22
- outputs=gr.TextArea(label="Command Output", show_copy_button=True),
 
 
 
23
  title="Linux Command Executor",
24
  description="Enter a Linux command and click submit to see the output.",
25
  flagging_mode="never",
26
- ).launch()
 
3
 
4
 
5
  def infer(command):
6
+ status = "Success"
7
+ result = None
8
  try:
9
+ result = subprocess.check_output(
10
  command,
11
  shell=True,
12
  stderr=subprocess.STDOUT,
13
  text=True,
14
  )
15
 
16
+ except Exception as e:
17
+ status = f"Error: {e.output}"
18
+
19
+ return status, result
20
 
21
 
22
  if __name__ == "__main__":
23
  gr.Interface(
24
  fn=infer,
25
  inputs=gr.Textbox(label="Linux Command", value="ls"),
26
+ outputs=[
27
+ gr.Textbox(label="Status", show_copy_button=True),
28
+ gr.TextArea(label="Command Output", show_copy_button=True),
29
+ ],
30
  title="Linux Command Executor",
31
  description="Enter a Linux command and click submit to see the output.",
32
  flagging_mode="never",
33
+ ).launch(ssr_mode=False)