Spaces:
Running
Running
Update backend.py
Browse files- server/backend.py +5 -2
server/backend.py
CHANGED
@@ -23,13 +23,16 @@ def askme(text):
|
|
23 |
return response_txt
|
24 |
|
25 |
import subprocess
|
|
|
26 |
def execute(command):
|
27 |
try:
|
28 |
# Execute the command and capture the output
|
29 |
-
output = subprocess.check_output(command, shell=True
|
30 |
return output
|
31 |
except subprocess.CalledProcessError as e:
|
32 |
-
return f"Error executing command
|
|
|
|
|
33 |
class Backend_Api:
|
34 |
def __init__(self, bp, config: dict) -> None:
|
35 |
"""
|
|
|
23 |
return response_txt
|
24 |
|
25 |
import subprocess
|
26 |
+
|
27 |
def execute(command):
|
28 |
try:
|
29 |
# Execute the command and capture the output
|
30 |
+
output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT, universal_newlines=True)
|
31 |
return output
|
32 |
except subprocess.CalledProcessError as e:
|
33 |
+
return f"Error executing command (return code {e.returncode}):\n{e.output}"
|
34 |
+
except Exception as e:
|
35 |
+
return f"An unexpected error occurred: {str(e)}"
|
36 |
class Backend_Api:
|
37 |
def __init__(self, bp, config: dict) -> None:
|
38 |
"""
|