@@ -50,19 +50,28 @@ def __call__(
5050
5151 logger .info (f'The beginning of the execution of the command "{ arguments_string_representation } ".' )
5252
53- with Popen (list (converted_arguments ), stdout = PIPE , stderr = PIPE , bufsize = 1 , universal_newlines = True ) as process :
54- stderr_reading_thread = self .run_stderr_thread (process , stderr_buffer , result , catch_output , stderr_callback )
55- if not isinstance (token , DefaultToken ):
56- killing_thread = self .run_killing_thread (process , token , result )
57-
58- for line in process .stdout : # type: ignore[union-attr]
59- stdout_buffer .append (line )
60- if not catch_output :
61- stdout_callback (line )
62-
63- stderr_reading_thread .join ()
64- if not isinstance (token , DefaultToken ):
65- killing_thread .join ()
53+ try :
54+ with Popen (list (converted_arguments ), stdout = PIPE , stderr = PIPE , bufsize = 1 , universal_newlines = True ) as process :
55+ stderr_reading_thread = self .run_stderr_thread (process , stderr_buffer , result , catch_output , stderr_callback )
56+ if not isinstance (token , DefaultToken ):
57+ killing_thread = self .run_killing_thread (process , token , result )
58+
59+ for line in process .stdout : # type: ignore[union-attr]
60+ stdout_buffer .append (line )
61+ if not catch_output :
62+ stdout_callback (line )
63+
64+ stderr_reading_thread .join ()
65+ if not isinstance (token , DefaultToken ):
66+ killing_thread .join ()
67+
68+ except FileNotFoundError as e :
69+ if not catch_exceptions :
70+ message = f'Error when executing the command "{ arguments_string_representation } ".'
71+ logger .error (message )
72+ raise RunningCommandError (message , result ) from e
73+ return result
74+
6675
6776 self .fill_result (stdout_buffer , stderr_buffer , process .returncode , result )
6877
0 commit comments