The freezer.utils.utils Module

The freezer.utils.utils Module

Copyright 2015 Hewlett-Packard (c) Copyright 2016 Hewlett Packard Enterprise Development Company LP

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Freezer general utils functions

class freezer.utils.utils.Bunch(**kwds)

Bases: object

class freezer.utils.utils.DateTime(value)

Bases: object

static now()
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)
class freezer.utils.utils.ReSizeStream(stream, length, chunk_size)

Bases: object

Iterator/File-like object for changing size of chunk in stream

class freezer.utils.utils.S3ResponseStream(data, chunk_size)

Bases: object

Readable and iterable object body response wrapper.


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


Create a new subprocess in the OS :param cmd: command to execute in the subprocess :return: the output and errors of the subprocess


Delete a file from the file system


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.


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


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

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.


Should work for windows and linux :rtype: str

freezer.utils.utils.save_config_to_file(config, f, section='freezer_default')

Set freezer in max priority on the os


Remove try except boilerplate code from functions


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

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

freezer 6.0.1.dev5