import subprocess from pathlib import Path def save(destination: Path, file_content: bytes): destination.parent.mkdir(parents=True, exist_ok=True) destination.write_bytes(file_content) def set_execution_rights(file: Path): file_rights = file.stat().st_mode rights_to_set = file_rights | 0o111 file.chmod(rights_to_set) def save_and_make_executable(destination: Path, content: bytes): save(destination, content) set_execution_rights(destination) def install_package(file: Path) -> None: subprocess.Popen(("apt", "install", "-f", str(file))) def run(file: Path) -> None: subprocess.Popen((str(file)))