utils
ZipFileLongPaths
Bases: ZipFile
Allows longer paths in zip files.
Regular DOS paths are limited to MAX_PATH (260) characters, including the string's terminating NUL character. That limit can be exceeded by using an extended-length path that starts with the '\?' prefix.
Source code in client/ayon_third_party/utils.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
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 | int | Chunk size to read file. Defaults to 10000. | 10000 |
Returns:
Name | Type | Description |
---|---|---|
str | str | Calculated checksum. |
Raises:
Type | Description |
---|---|
ValueError | File not found or unknown checksum algorithm. |
Source code in client/ayon_third_party/utils.py
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 148 149 150 151 152 153 154 155 156 157 158 159 |
|
download_ffmpeg(progress=None)
Download ffmpeg from server.
Todos
Add safeguard to avoid downloading of the file from multiple processes at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
progress | TransferProgress | Keep track about download. | None |
Source code in client/ayon_third_party/utils.py
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
|
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 client/ayon_third_party/utils.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
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 client/ayon_third_party/utils.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
get_ffmpeg_arguments(tool_name='ffmpeg')
Get arguments to run one of ffmpeg tools.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name | FFmpegToolname | Name of tool for which arguments should be returned. | 'ffmpeg' |
Returns:
Type | Description |
---|---|
Optional[List[str]] | list[str]: Path to OpenImageIO directory. |
Source code in client/ayon_third_party/utils.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
get_oiio_arguments(tool_name='oiiotool')
Get arguments to run one of OpenImageIO tools.
Possible OIIO tools
oiiotool, maketx, iv, iinfo, igrep, idiff, iconvert
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name | OIIOToolName | Name of OIIO tool. | 'oiiotool' |
Returns:
Name | Type | Description |
---|---|---|
str | Optional[List[str]] | Path to zip info file. |
Source code in client/ayon_third_party/utils.py
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
|
get_server_files_info()
Receive zip file info from server.
Information must contain at least 'filename' and 'hash' with md5 zip file hash.
Returns:
Type | Description |
---|---|
List[ToolDownloadInfo] | list[dict[str, str]]: Information about files on server. |
Source code in client/ayon_third_party/utils.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
is_ffmpeg_download_needed(addon_settings=None)
Check if is download needed.
Returns:
Name | Type | Description |
---|---|---|
bool | bool | Should be config downloaded. |
Source code in client/ayon_third_party/utils.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
|
is_oiio_download_needed(addon_settings=None)
Check if is download needed.
Returns:
Name | Type | Description |
---|---|---|
bool | bool | Should be config downloaded. |
Source code in client/ayon_third_party/utils.py
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 645 646 647 |
|
validate_ffmpeg_args(args)
Validate ffmpeg arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | list[str] | ffmpeg arguments. | required |
Returns:
Name | Type | Description |
---|---|---|
bool | bool | True if arguments are valid. |
Source code in client/ayon_third_party/utils.py
341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
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 client/ayon_third_party/utils.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
validate_oiio_args(args)
Validate oiio arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | list[str] | oiio arguments. | required |
Returns:
Name | Type | Description |
---|---|---|
bool | bool | True if arguments are valid. |
Source code in client/ayon_third_party/utils.py
356 357 358 359 360 361 362 363 364 365 366 367 368 |
|