Utils
utils
download_and_extract(url: str, save_path: Path, timeout: float = RELEASE_DOWNLOAD_TIMEOUT, overwrite: bool = False, progress_callback: Callable[[str, int, int | None], None] | None = None, cancel: Callable[[], bool] | None = None, sha512: str | None = None) -> None
Downloads a zip file from the given URL and extracts its contents.
Nothing at save_path changes until extraction has fully succeeded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to download the zip file from. |
required |
save_path
|
Path
|
The directory path to save the extracted contents to. |
required |
timeout
|
float
|
HTTP request timeout in seconds. |
RELEASE_DOWNLOAD_TIMEOUT
|
overwrite
|
bool
|
Whether to replace a non-empty |
False
|
progress_callback
|
Callable[[str, int, int | None], None] | None
|
Called as |
None
|
cancel
|
Callable[[], bool] | None
|
Checked before each downloaded chunk; return True to stop. Extraction can't be cancelled. |
None
|
sha512
|
str | None
|
Expected hex SHA-512 of the zip ( |
None
|
Raises:
| Type | Description |
|---|---|
FileExistsError
|
If |
DownloadCancelled
|
If |
ChecksumError
|
If the zip doesn't match |
DownloadError
|
On network or write failure. |
ExtractError
|
On an invalid or empty zip, or a failed extraction. |
find_binary(dir_path: Path) -> Path | None
Finds the Godot binary in a given folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_path
|
Path
|
The path to the folder containing the binary. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The path to the Godot binary if found, otherwise None. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the provided path is not a valid directory. |
NotImplementedError
|
If the current platform is not supported. |
start(binary_path: Path, args: Sequence[str] = (), *, project: Path | None = None, output: Path | None = None) -> subprocess.Popen
Launches Godot detached: the project manager, or project in the editor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_path
|
Path
|
The full path to the Godot binary file. |
required |
args
|
Sequence[str]
|
Extra command-line arguments for Godot. |
()
|
project
|
Optional[Path]
|
A |
None
|
output
|
Optional[Path]
|
File that receives Godot's stdout and stderr. |
None
|
Returns:
| Type | Description |
|---|---|
Popen
|
The started Godot process. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
OSError
|
If the binary can't be started. |