Spaces:
Runtime error
Runtime error
Ramesh-vani
commited on
Commit
•
01531ac
1
Parent(s):
15f36b1
Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,14 @@ import gradio
|
|
2 |
import subprocess
|
3 |
|
4 |
def run_command(command):
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
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 |
|