pyats.aereport.utils package

utils – Utilities module

This module contains helper classes and functions.

pyats.aereport.utils.format_time_portion(time_portion)

Makes sure that a time portion (hours, minutes, seconds) is at least two digits. It doesn’t accept negative values.

Parameters

time_portion (int) – Value of hours or minutes or seconds

Returns

A string of at least 2 digits

Return type

str

pyats.aereport.utils.format_timedelta(tdelta)

Given a timedelta object, it returns a string in the form: hh:mm:ss

Parameters

tdelta (timedelta) –

Returns

A string in the form hh:mm:ss

Return type

str

pyats.aereport.utils.get_file_name(filepath)

Gets the file name portion of path/to/a/file :param filepath: Path to the file :type filepath: str

Returns

filename – Name of the file

Return type

str

pyats.aereport.utils.get_file_size(filepath)

Gets the size of the provided file (in bytes)

Parameters

filepath (str) – Path to the file

Returns

filesize – Size of the file in bytes

Return type

int

pyats.aereport.utils.get_ppid(pid)

Gets the parent process ID of the given process

Parameters

pid (str or int) – Process ID

Returns

ppid – Parent process ID as string

Return type

str

Raises

psutil.NoSuchProcess – Raised when no process with the given PID is found in the current process list or when a process no longer exists (zombie)

pyats.aereport.utils.print_block(block_title, block_content)

Prints a formatted block with a title and content

Submodules

argsvalidator – ArgsValidator Class

This module contains a ArgsValidator which can be used to verify that args (or any dictionary-like members) satisfy a given criteria.

class pyats.aereport.utils.argsvalidator.ArgsValidator

Bases: object

ArgsValidator is a helper class that can be used from anywhere to verify that method arguments satisfy certain criteria such as mandatory/optional, datatype, etc.

classmethod validate(args_def, restrict=False, **kwargs)
Parameters

args_def (list) – list of tuples containing criteria of anticipated arguments e.g. mandatory/optional, type, etc Each tuple will look like this: (variable_name, ‘m’/’o’, [possible types], [valid_keys/options], [dic_mand_keys]) e.g. [ (var1, ‘m’, [str]), (var2, ‘o’, [int, bool]), (var3, ‘m’, dict, [‘key1’, ‘key2’], [‘key1’]) ]

Returns

Return type

Nothing

Raises