From c9e8a2df18532adda74ceeb1c7b6686aa604d964 Mon Sep 17 00:00:00 2001 From: Prayas Dey Date: Mon, 10 Aug 2026 23:57:04 +0530 Subject: [PATCH 1/2] fix(Execute Shell Command): fix exception return tuple, print formatting and add tests (fixes #463) --- Execute Shell Command/execute_shell_command.py | 6 +++--- Execute Shell Command/execute_shell_command_test.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Execute Shell Command/execute_shell_command.py b/Execute Shell Command/execute_shell_command.py index 077c370e..23a7140c 100644 --- a/Execute Shell Command/execute_shell_command.py +++ b/Execute Shell Command/execute_shell_command.py @@ -8,11 +8,11 @@ def execute_shell_command(command): out, err = proc.communicate() return_code = proc.returncode if err: - print(str(err)) + print(err.decode('utf8', errors='ignore')) return out, return_code except Exception as err: - print("Exception Occurred while executing module : %s", str(err)) - return 105 + print(f"Exception Occurred while executing module : {err}") + return b'', 105 if __name__ == '__main__': command ='echo Deepak' diff --git a/Execute Shell Command/execute_shell_command_test.py b/Execute Shell Command/execute_shell_command_test.py index db063049..835f517c 100644 --- a/Execute Shell Command/execute_shell_command_test.py +++ b/Execute Shell Command/execute_shell_command_test.py @@ -7,6 +7,10 @@ def test_shell_command(self): result, status = shell.execute_shell_command('echo Khanna') self.assertEqual(result.decode('utf8').rstrip("\r\n"), 'Khanna') + def test_shell_command_non_zero_status(self): + result, status = shell.execute_shell_command('non_existent_command_12345') + self.assertNotEqual(status, 0) + self.assertIsInstance(result, bytes) + if __name__ == '__main__': unittest.main(verbosity=2) - From 501625cde40ef99ddbac0f3f549509e4e26798d5 Mon Sep 17 00:00:00 2001 From: Prayas Dey Date: Mon, 10 Aug 2026 23:57:19 +0530 Subject: [PATCH 2/2] fix(Execute Shell Command): fix exception return tuple, print formatting and add tests (fixes #463)