ayon_common
calculate_file_checksum(filepath, checksum_algorithm, chunk_size=10000)
Calculate file checksum for given algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath | str | Path to a file. | required |
checksum_algorithm | str | Algorithm to use. ('md5', 'sha1', 'sha256') | required |
chunk_size | Optional[int] | Chunk size to read file. Defaults to 10000. | 10000 |
Returns:
| Name | Type | Description |
|---|---|---|
str | Calculated checksum. |
Raises:
| Type | Description |
|---|---|
ValueError | File not found or unknown checksum algorithm. |
Source code in common/ayon_common/utils.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | |
extract_archive_file(archive_file, dst_folder=None)
Extract archived file to a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archive_file | str | Path to a archive file. | required |
dst_folder | Optional[str] | Directory where content will be extracted. By default, same folder where archive file is. | None |
Source code in common/ayon_common/utils.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
get_archive_ext_and_type(archive_file)
Get archive extension and type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archive_file | str | Path to archive file. | required |
Returns:
| Type | Description |
|---|---|
Tuple[Optional[str], Optional[str]] | Tuple[str, str]: Archive extension and type. |
Source code in common/ayon_common/utils.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | |
get_ayon_appdirs(*args)
Local app data directory of AYON launcher.
Deprecated
The function was replaced with 'get_launcher_local_dir' or 'get_launcher_storage_dir' based on usage. Deprecated since 1.1.0 .
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args | Iterable[str] | Subdirectories/files in local app data dir. | () |
Returns:
| Name | Type | Description |
|---|---|---|
str | Path to directory/file in local app data dir. |
Source code in common/ayon_common/utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_ayon_launch_args(*args)
Launch arguments that can be used to launch ayon process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args | str | Additional arguments. | () |
Returns:
| Type | Description |
|---|---|
List[str] | list[str]: Launch arguments. |
Source code in common/ayon_common/utils.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
get_downloads_dir()
Downloads directory path.
Each platform may use different approach how the downloads directory is received. This function will try to find the directory and return it.
Returns:
| Type | Description |
|---|---|
str | Union[str, None]: Path to downloads directory or None if not found. |
Source code in common/ayon_common/utils.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
get_launcher_local_dir(*subdirs, create=False)
Get local directory for launcher.
Local directory is used for storing machine or user specific data.
The location is user specific.
Note
This function should be called at least once on bootstrap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*subdirs | str | Subdirectories relative to local dir. | () |
create | Optional[bool] | Create the folder if it does not exist. | False |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | Path to local directory. |
Source code in common/ayon_common/utils.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
get_launcher_storage_dir(*subdirs, create=False)
Get storage directory for launcher.
Storage directory is used for storing shims, addons, dependencies, etc.
It is not recommended, but the location can be shared across multiple machines.
Note
This function should be called at least once on bootstrap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*subdirs | str | Subdirectories relative to storage dir. | () |
create | Optional[bool] | Create the folder if it does not exist. | False |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | Path to storage directory. |
Source code in common/ayon_common/utils.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
get_local_site_id()
Get local site identifier.
Site id is created if does not exist yet.
Returns:
| Name | Type | Description |
|---|---|---|
str | str | Site id. |
Source code in common/ayon_common/utils.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
is_dev_mode_enabled()
Check if dev is enabled.
A dev bundle is used when dev is enabled.
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | Dev is enabled. |
Source code in common/ayon_common/utils.py
160 161 162 163 164 165 166 167 168 169 | |
is_staging_enabled()
Check if staging is enabled.
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | True if staging is enabled. |
Source code in common/ayon_common/utils.py
150 151 152 153 154 155 156 157 | |
validate_file_checksum(filepath, checksum, checksum_algorithm)
Validate file checksum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath | str | Path to file. | required |
checksum | str | Hash of file. | required |
checksum_algorithm | str | Type of checksum. | required |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | Hash is valid/invalid. |
Raises:
| Type | Description |
|---|---|
ValueError | File not found or unknown checksum algorithm. |
Source code in common/ayon_common/utils.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |