freezer.utils.utils module¶
Freezer general utils functions
-
class
freezer.utils.utils.
Bunch
(**kwds)¶ Bases:
object
-
class
freezer.utils.utils.
Namespace
(obj={})¶ Bases:
dict
A dict subclass that exposes its items as attributes.
Warning: Namespace instances do not have direct access to the dict methods.
-
static
delattr
(ns, name)¶
-
classmethod
from_mapping
(ns, names=None)¶
-
classmethod
from_object
(obj, names=None)¶
-
classmethod
from_sequence
(seq, names=None)¶
-
static
getattr
(ns, name)¶
-
static
hasattr
(ns, name)¶
-
static
setattr
(ns, name, value)¶
-
static
-
class
freezer.utils.utils.
ReSizeStream
(stream, length, chunk_size)¶ Bases:
object
Iterator/File-like object for changing size of chunk in stream
-
next
()¶
-
read
(chunk_size)¶
-
-
class
freezer.utils.utils.
S3ResponseStream
(data, chunk_size)¶ Bases:
object
Readable and iterable object body response wrapper.
-
next
()¶
-
read
(length=None)¶
-
-
freezer.utils.utils.
alter_proxy
(proxy)¶ Read proxy option from dictionary and alter the HTTP_PROXY and/or HTTPS_PROXY system variables
-
freezer.utils.utils.
create_dir
(directory, do_log=True)¶ Creates a directory if it doesn’t exists and write the execution in the logs
-
freezer.utils.utils.
create_dir_tree
(directory_path)¶
-
freezer.utils.utils.
create_subprocess
(cmd)¶ Create a new subprocess in the OS :param cmd: command to execute in the subprocess :return: the output and errors of the subprocess
-
freezer.utils.utils.
date_to_timestamp
(date)¶
-
freezer.utils.utils.
delete_file
(path_to_file)¶ Delete a file from the file system
-
freezer.utils.utils.
dequote
(s)¶ If a string has single or double quotes around it, remove them. Make sure the pair of quotes match. If a matching pair of quotes is not found, return the string unchanged.
-
freezer.utils.utils.
exclude_path
(path, exclude)¶ Tests if path is to be excluded according to the given pattern. :return: True if path matches the exclude pattern, False otherwise
-
freezer.utils.utils.
execute_walk_callback
(count, filepath, callback, *kargs, **kwargs)¶ Execute the callback function adding the file path to its argument list. Increments the file counter and returns it. NB: the callback function must be defined with the filepath argument.
-
freezer.utils.utils.
find_executable
(name)¶
-
freezer.utils.utils.
get_executable_path
(binary)¶ This function returns the executable path of a given binary if it is found in the system. :param binary: :type binary: str :rtype: str :return: Absolute Path to the executable file
-
freezer.utils.utils.
get_mount_from_path
(path)¶ Take a file system path as argument and return the mount point for that file system path.
- Parameters
path – file system path
- Returns
mount point of path, rest of the path
-
freezer.utils.utils.
human2bytes
(s)¶ Attempts to guess the string format based on default symbols set and return the corresponding bytes as an integer. When unable to recognize the format ValueError is raised.
-
freezer.utils.utils.
is_bsd
()¶
-
freezer.utils.utils.
is_empty_dir
(path)¶
-
freezer.utils.utils.
openssl_path
()¶
-
freezer.utils.utils.
path_join
(*args)¶ Should work for windows and linux :rtype: str
-
freezer.utils.utils.
save_config_to_file
(config, f, section='freezer_default')¶
-
freezer.utils.utils.
set_max_process_priority
()¶ Set freezer in max priority on the os
-
freezer.utils.utils.
shield
(func)¶ Remove try except boilerplate code from functions
-
freezer.utils.utils.
tar_path
()¶ This function returns tar binary path
-
freezer.utils.utils.
wait_for
(condition_func, wait_interval, timeout, message=None, kwargs={})¶
-
freezer.utils.utils.
walk_path
(path, exclude, ignorelinks, callback, *kargs, **kwargs)¶ Walk a directory and execute a callback function for each file found. If path to a single file is given, the callback is excuted for this file. The callback is also executed and counted for an empty directory. :return: int with the number of files walked