dmit.ostools module
Module for OS relevant functions
- dmit.ostools.clean(files)[source]
Removes files from the system. Note that filenames must be given as full paths
- Parameters
files (list) – List of files to remove.
- dmit.ostools.does_dir_exist(f)[source]
Check if directory exist
- Parameters
f (str) – name of directory to check
- Returns
state – Whether the directory exist (True) or not exist (False)
- Return type
boolean
- dmit.ostools.does_file_exist(f)[source]
Check if file exist
- Parameters
f (str) – name of file to check
- Returns
state – Whether the file exist (True) or not exist (False)
- Return type
boolean
- dmit.ostools.find_files(directory, prefix='', postfix='', recursive=True, onlyfiles=True, fullpath=False, olderthan=None, inorder=False)[source]
Find files in a directory.
- Parameters
directory (str) – Directory to search in
prefix (str (optional)) – Only remove files with this prefix
postfix (str (optional)) – Only remove files with the postfix
recursive (Boolean (optional)) – Go into directories recursively. Defaults to True
onlyfiles (Boolean (optional)) – Show only files. Defaults to True
fullpath (Boolean (optional)) – Give full path. Defaults to False. If recursive=True, fullpath is given automatically.
olderthan (int (optional)) – Match only files older than X seconds from now. Defaults to None
inorder (Boolean (optional)) – Return sorted list of filenames. Defaults to False
- Returns
files – List containing file names that matches criterias
- Return type
list
Notes
files = find_files(‘/foo/’, prefix=””, postfix=””, recursive=False, onlyfiles=True, fullpath=True, olderthan=86400*100)