Ensure output directory exists when using create-device

This commit is contained in:
rlaphoenix 2023-07-07 19:42:59 +01:00
parent db6eaef450
commit 29693bedf6
1 changed files with 7 additions and 1 deletions

View File

@ -230,7 +230,13 @@ def create_device(
except UnidecodeError as e: except UnidecodeError as e:
raise click.ClickException(f"Failed to sanitize name, {e}") raise click.ClickException(f"Failed to sanitize name, {e}")
out_path = (output or Path.cwd()) / f"{name}_{device.system_id}_l{device.security_level}.wvd" if output:
out_dir = output
out_dir.mkdir(parents=True, exist_ok=True)
else:
out_dir = Path.cwd()
out_path = out_dir / f"{name}_{device.system_id}_l{device.security_level}.wvd"
out_path.write_bytes(wvd_bin) out_path.write_bytes(wvd_bin)
log.info("Created Widevine Device (.wvd) file, %s", out_path.name) log.info("Created Widevine Device (.wvd) file, %s", out_path.name)