zip_tools
_create_zip(folder, output)
¶
Zip a folder into a zip-file or into a BytesIO.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder |
str
|
Folder to be zipped. |
required |
output |
T
|
Either a string with the path of the zip file, or a BytesIO object. |
required |
Returns:
Type | Description |
---|---|
T
|
Either the zip-file path string, or the modified BytesIO object. |
Source code in fractal_server/zip_tools.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
_folder_can_be_deleted(folder)
¶
Given the path of a folder as string, returns False
if either:
- the related zip file {folder}.zip
does already exists,
- the folder and the zip file have a different number of internal files,
- the zip file has a very small size.
Otherwise returns True
.
Source code in fractal_server/zip_tools.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 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 |
|
_zip_folder_to_byte_stream_iterator(folder)
¶
Returns byte stream with the zipped log folder of a job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder |
str
|
the folder to zip |
required |
Source code in fractal_server/zip_tools.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
_zip_folder_to_file_and_remove(folder)
¶
Creates a ZIP archive of the specified folder and removes the original folder (if it can be deleted).
This function performs the following steps:
1. Creates a ZIP archive of the folder
and names it with a temporary
suffix _tmp.zip
.
2. Renames the ZIP removing the suffix (this would possibly overwrite a
file with the same name already present).
3. Checks if the folder can be safely deleted using the
_folder_can_be_deleted
function. If so, deletes the original folder.
Source code in fractal_server/zip_tools.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|