in troubleshooting/create_snapshot.py [0:0]
def run_cmd(cmd: str, subfolder: str, output_dir: pathlib.Path): # noqa: E999
output_path = output_dir / subfolder / cmd.replace(' ', '_')
output_path.parent.mkdir(parents=True, exist_ok=True)
print("Executing: {}... ".format(cmd), end='')
backoff_timer = 1
backoff_count = 0
with open(output_path, mode='w') as output_file:
while True:
if backoff_count > BACKOFF_LIMIT:
print('[ FAIL ]')
return
process = subprocess.run(cmd, stdout=output_file,
stderr=output_file,
timeout=60,
shell=True)
if not process.returncode:
print("[ DONE ]")
return
print("\nCommand failed, trying again in {}s. ' \
'Error output: {}".format(backoff_timer, process.stderr))
time.sleep(backoff_timer)
backoff_timer *= 2
backoff_count += 1