mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-17 11:10:23 +00:00
actions_utils: Fix issue with collecting stdout/stderr
- When an exception is raised in subprocess.run(), for that call the stdout and stderr are not being collected. Any previous successful calls are being collected. - This also fixes issues with adding an existing backup repository back after removal. Capturing stderr is essential for raising the proper exceptions and working correctly. Tests: - Remove an existing backup repository and add it back again. It fails with the patches and succeeds with the patches. - Remove an existing encrypted backup repository and add it back again with the wrong password. A proper error message is shown 'Incorrect encryption passphrase'. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
f559870d3e
commit
355812c9f2
@ -836,11 +836,20 @@ def run(command, **kwargs):
|
||||
if collect_stderr:
|
||||
kwargs['stderr'] = subprocess.PIPE
|
||||
|
||||
process = subprocess.run(command, **kwargs)
|
||||
if collect_stdout and hasattr(actions.thread_storage, 'stdout'):
|
||||
actions.thread_storage.stdout += process.stdout
|
||||
try:
|
||||
process = subprocess.run(command, **kwargs)
|
||||
if collect_stdout and hasattr(actions.thread_storage, 'stdout'):
|
||||
actions.thread_storage.stdout += process.stdout
|
||||
|
||||
if collect_stderr and hasattr(actions.thread_storage, 'stderr'):
|
||||
actions.thread_storage.stderr += process.stderr
|
||||
if collect_stderr and hasattr(actions.thread_storage, 'stderr'):
|
||||
actions.thread_storage.stderr += process.stderr
|
||||
except subprocess.CalledProcessError as exception:
|
||||
if exception.stdout and hasattr(actions.thread_storage, 'stdout'):
|
||||
actions.thread_storage.stdout += exception.stdout
|
||||
|
||||
if exception.stderr and hasattr(actions.thread_storage, 'stderr'):
|
||||
actions.thread_storage.stderr += exception.stderr
|
||||
|
||||
raise exception
|
||||
|
||||
return process
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user