Divyansh Singh 2 years ago
parent
commit
1e3a3bf1e7
2 changed files with 3 additions and 5 deletions
  1. 2 4
      borgmatic/execute.py
  2. 1 1
      tests/unit/test_execute.py

+ 2 - 4
borgmatic/execute.py

@@ -220,10 +220,8 @@ def execute_command_and_capture_output(
     stdout. If shell is True, execute the command within a shell. If an extra environment dict is
     stdout. If shell is True, execute the command within a shell. If an extra environment dict is
     given, then use it to augment the current environment, and pass the result into the command. If
     given, then use it to augment the current environment, and pass the result into the command. If
     a working directory is given, use that as the present working directory when running the command.
     a working directory is given, use that as the present working directory when running the command.
-    If raise on exit code one is False, then treat exit code 1 as a warning instead of an error.
 
 
-    Raise subprocesses.CalledProcessError if an error occurs while running the command, or if the
-    command exits with a non-zero exit code and raise on exit code one is True.
+    Raise subprocesses.CalledProcessError if an error occurs while running the command.
     '''
     '''
     log_command(full_command)
     log_command(full_command)
     environment = {**os.environ, **extra_environment} if extra_environment else None
     environment = {**os.environ, **extra_environment} if extra_environment else None
@@ -239,7 +237,7 @@ def execute_command_and_capture_output(
         )
         )
         logger.warning('Command output: {}'.format(output))
         logger.warning('Command output: {}'.format(output))
     except subprocess.CalledProcessError as error:
     except subprocess.CalledProcessError as error:
-        if exit_code_indicates_error(error.returncode):
+        if exit_code_indicates_error(command, error.returncode):
             raise
             raise
         output = error.output
         output = error.output
         logger.warning('Command output: {}'.format(output))
         logger.warning('Command output: {}'.format(output))

+ 1 - 1
tests/unit/test_execute.py

@@ -254,7 +254,7 @@ def test_execute_command_and_capture_output_returns_output_when_error_code_is_on
     assert output == expected_output
     assert output == expected_output
 
 
 
 
-def test_execute_command_and_capture_output_returns_output_when_error_code_not_one():
+def test_execute_command_and_capture_output_raises_when_command_errors():
     full_command = ['foo', 'bar']
     full_command = ['foo', 'bar']
     expected_output = '[]'
     expected_output = '[]'
     flexmock(module.os, environ={'a': 'b'})
     flexmock(module.os, environ={'a': 'b'})