Skip to content

Commit efafb3f

Browse files
added try-catch in output and error_log
1 parent de2914e commit efafb3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

shuffle-tools/1.2.0/src/app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,11 +2632,19 @@ def run_ssh_command(self, host, port, user_name, private_key_file_id, password,
26322632

26332633
try:
26342634
stdin, stdout, stderr = ssh_client.exec_command(str(command))
2635+
try:
2636+
errorLog = stderr.read().decode(errors='ignore')
2637+
except Exception as e:
2638+
errorLog = f"Failed to read stderr {e}"
2639+
try:
2640+
output = stdout.read().decode(errors='ignore')
2641+
except Exception as e:
2642+
output = f"Failed to read stdout {e}"
26352643

26362644
except Exception as e:
26372645
return {"success":"false","message":str(e)}
26382646

2639-
return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_logs": stderr.read().decode(errors='ignore')}
2647+
return {"success":"true","output": output, "error_logs": errorLog}
26402648

26412649
def cleanup_ioc_data(self, input_data):
26422650
# Remove unecessary parts like { and }, quotes etc

0 commit comments

Comments
 (0)