Skip to content

Commit

Permalink
Update executor.py to handle spaces in binary path (#489)
Browse files Browse the repository at this point in the history
* Update executor.py to handle spaces in binary path

* Update test_executor.py for new path

* Update test_executor.py

* Update test_executor.py to pass test

* Update test_executor.py
  • Loading branch information
djps authored Oct 27, 2024
1 parent 67c98d1 commit b48de13
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions kwave/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ def _make_binary_executable(self):

def run_simulation(self, input_filename: str, output_filename: str, options: str):
command = (
f"{self.execution_options.system_string} "
f"{self.execution_options.binary_path} "
f"-i {input_filename} "
f"-o {output_filename} "
f"{options}"
f"{self.execution_options.system_string}" f'"{self.execution_options.binary_path}" -i {input_filename} -o {output_filename} {options}'
)

try:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_run_simulation_success(self):
sensor_data = executor.run_simulation("input.h5", "output.h5", "options")

normalized_path = os.path.normpath(self.execution_options.binary_path)
expected_command = f"{self.execution_options.system_string} " f"{normalized_path} " f"-i input.h5 " f"-o output.h5 " f"options"
expected_command = f"{self.execution_options.system_string}" f'"{normalized_path}" -i input.h5 ' f"-o output.h5 " f"options"

self.mock_popen.assert_called_once_with(expected_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
self.mock_proc.communicate.assert_called_once()
Expand Down

0 comments on commit b48de13

Please sign in to comment.