Ramesh-vani commited on
Commit
01531ac
1 Parent(s): 15f36b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -2,21 +2,14 @@ import gradio
2
  import subprocess
3
 
4
  def run_command(command):
5
- try:
6
- result = subprocess.run(
7
- command,
8
- shell=True,
9
- check=True,
10
- text=True,
11
- stdout=subprocess.PIPE,
12
- stderr=subprocess.PIPE,
13
- input=None # You can provide input to the command here as a string
14
- )
15
- return result.stdout.strip()
16
- except subprocess.CalledProcessError as e:
17
- return f"Error: {e}"
18
- except Exception as e:
19
- return f"An error occurred: {e}"
20
 
21
  # Example usage
22
 
 
2
  import subprocess
3
 
4
  def run_command(command):
5
+ process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6
+ output, error = process.communicate()
7
+ if process.returncode == 0:
8
+ result = output.decode('utf-8')
9
+ return result
10
+ else:
11
+ result = error.decode('utf-8')
12
+ return result
 
 
 
 
 
 
 
13
 
14
  # Example usage
15