diff --git a/backupmanager.j2 b/backupmanager.j2 index dcc41ed..b5f6fdf 100644 --- a/backupmanager.j2 +++ b/backupmanager.j2 @@ -47,7 +47,11 @@ def run_command(command, env=None): current_env = os.environ.copy() if env is not None: current_env.update(env) + sys.stdout.flush() + sys.stderr.flush() process = subprocess.run(command, shell=True, env=current_env) + sys.stdout.flush() + sys.stderr.flush() if process.returncode != 0: raise RuntimeError(f"Command '{command}' failed with return code {process.returncode}, environment is {env}") @@ -55,8 +59,12 @@ def get_command(command, env=None, full_return=False): current_env = os.environ.copy() if env is not None: current_env.update(env) + sys.stdout.flush() + sys.stderr.flush() process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=current_env) output, error = process.communicate() + sys.stdout.flush() + sys.stderr.flush() return_code = process.poll() if full_return: return output.decode().strip(), error.decode().strip(), return_code