files_management module
- class files_management.UniqueAndTime(unique)
Bases:
object
Node of a heap to keep track of the unique used. After a time of FILE_LIFE_S seconds, all files associated with this unique is eliminated.
- Parameters:
- uniquestr
unique string
- Attributes:
- uniquestr
Unique string
- timefloat
time at which this node was created
- files_management.add_to_heap(unique)
Add unique to used uniques.
- Parameters:
- uniquestr
unique used
See also
- files_management.add_to_unique_not_used(unique)
Add unique to uniques created but never used.
- Parameters:
- uniquestr
unique never used
- files_management.check_config_file(file)
Check if setting file is safe and well formatted
- Parameters:
- fileFileStorage
setting file
- Returns:
- bool
True if the file is safe, False otherwise
- files_management.check_files(files)
Check if association files are safe and well formatted
- Parameters:
- filesUnion[List[FileStorage], list]
association files
- Returns:
- bool
True if all files are safe, False otherwise
- files_management.check_request(unique)
Check if unique as already associated to a task
- Parameters:
- uniquestr
unique string
- Returns:
- bool
True if the unique can be associated to another task, False otherwise
- files_management.check_unique(unique)
Check if a unique exists
- Parameters:
- uniquestr
unique to check
- Returns:
- bool
True if the unique exists, False otherwise
- files_management.create_dir(unique)
Creates dir for unique. DOES NOT ADD unique to Heap
- Parameters:
- uniquestr
unique
- files_management.get_images_list(unique)
Get all the images associated with a unique
- Parameters:
- uniquestr
unique
- Returns:
- List[str]
list of the images path
- files_management.get_path(unique)
Get the path where are saved files associated with a specific unique
- Parameters:
- uniquestr
unique string
- Returns:
- pathstr
path = UPLOAD_FOLDER + unique + SECRET_ADD
- files_management.get_path_img_res(unique, img_name)
Get the path of a image associated with a unique
- Parameters:
- uniquestr
unique
- img_namestr
name of the image with extension
- Returns:
- str
image path
- files_management.get_path_results(unique)
Get the path where file with results is saved
- Parameters:
- uniquestr
unique string
- Returns:
- str
path of result file
- files_management.get_setting_file_name(file)
Create file name for the setting file, preserving its extension
- Parameters:
- fileFileStorage
setting file
- Returns:
- str
SETUP_FILE + extension
- files_management.get_standard_setting_file_name()
Get the standard name for the setting file
- Returns:
- str
name of the standard file (.yaml)
- files_management.is_file_safe(file, is_setting)
Check if file is safe: extension and if name contains just alphanumerical char or ‘_’ and len less than L.
- Parameters:
- fileFileStorage
file to check
- is_settingbool
if False check file as association file, if True check file as setting file
- Returns:
- bool
True if the file is safe, False otherwise
- files_management.new_unique_name()
Create a new unique
- Returns:
- str
new unique
- files_management.remove_from_unique_not_used(unique)
Unique was used or its lifetime is expired. Remove unique to uniques created but never used.
- Parameters:
- uniquestr
unique
- files_management.routine_clean_heap()
Function to stat the routine to clean up uniques used. Called every ROUTINE_S seconds.
See also
- files_management.routine_clean_uniques_not_used()
Function to stat the routine to clean up uniques created but never used. Called every ROUTINE_UNIQUE_NOT_USED seconds.
- files_management.save_file(file, unique, is_setting=False)
Save file in unique dir (get_path(unique))
- Parameters:
- fileUnion[List[FileStorage], list]
association files
- uniquestr
unique associated with the file
- is_setting: str, default=False
Set to True if file is a setting file, set to False if file is an association file
- files_management.save_files(files, unique)
Save files in unique dir (get_path(unique))
- Parameters:
- filesUnion[List[FileStorage], list]
association files
- uniquestr
unique associated with the files