Common Libs
Module with common libs used in MFD modules.
Supported classes:
TimeoutCounter
Params:
timeout: float- Time, after which bool(obj) will become Truefirst_check_start: bool- IfTrue- start counting from the firstbool(obj)attempt, otherwise counting is started at object creation.
Representation:
bool(obj:TimeoutCounter)returnsFalseif timer last less than timeout andTrueif more.
DisableLogger
Context manager to temporarily suppress log messages.
By default, suppresses all log messages from levels 0 - MODULE_DEBUG (inclusive).
Can be parametrized by providing level argument.
Usage
from mfd_common_libs import DisableLogger
with DisableLogger():
# do something
from mfd_common_libs import DisableLogger
with DisableLogger(level=logging.INFO):
# do something
Supported features:
log_func_info
It's a decorator, which logs name and passed arguments to decorated method. Uses given logger Params:
logger- object of Logger
Usage
import logging
from mfd_common_libs import log_func_info
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
@log_func_info(logger)
def calling_someone(someone):
pass
calling_someone('Adam')
logs MODULE_DEBUG:__main__:Calling func: calling_someone with arguments: ['Adam']
os_supported
It's a decorator, which checks if OS of connected device is expected/supported. It can be used in implementation of modules.
Requires Connection object from mfd_connect as argument in function!
Params:
- handle OSName written as python arguments eg.
@os_supported(OSName.LINUX)or@os_supported(OSName.LINUX, OSName.WINDOWS)
Raises OSSupportedDecoratorErrorif not found necessary 'connection' and UnexpectedOSException when OS is unexpected.
Usage
Usually usage:
from mfd_common_libs import os_supported
from mfd_typing import OSName
class MyModule:
"""My module."""
@os_supported(OSName.LINUX, OSName.WINDOWS, OSName.FREEBSD)
def __init__(self, *, connection):
self._conn = connection
When your class doesn't have implemented custom __init__, but uses from parent, you need to define __init__ like as bottom:
from mfd_common_libs import os_supported
from mfd_typing import OSName
class MyModule:
"""My module."""
def __init__(self, *, connection):
self._conn = connection
class MyModuleWithInherit(MyModule):
"""My child module."""
__init__ = os_supported(OSName.LINUX)(MyModule.__init__)
def some_method(self):
pass
Supported methods:
add_logging_level(level_name: str, level_value: int) -> None- Add a new logging level to theloggingmodule. Does nothing if logging name is already declared.add_logging_group(level_group: LevelGroup) -> None- Add all log levels related to the given group to the logging module.
Basically, add all log levels which include LevelGroup substring.
So for exampleadd_logging_group(LevelGroup.BL)will add:log_levels.BL_STEPlog_levels.BL_INFOlog_levels.BL_DEBUG
Data Structures
class LevelGroup(Enum):
"""Names of log levels' groups."""
BL = auto()
MFD = auto()
TEST = auto()
Supported Logging Levels
MODULE_DEBUGlog level should be used when any activity during debugging the module is worth logging.CMDlog level should be used only for executed command line (ex. from mfd-connect execute_command method).OUTlog level should be used only for logging output from executed command line (ex. from mfd-connect execute_command method).TEST_PASSlog level should be used in test cases to provide information about test result.TEST_FAILlog level should be used in test cases to provide information about test result.TEST_STEPlog level should be used in test cases to provide information on high level steps being performed.TEST_INFOlog level should be used in test cases to provide additional information between step and debug.TEST_DEBUGlog level should be used in test cases for debug information about steps performed.BL_STEPlog level should be used in Business Logic to provide information on high level steps being performed.BL_INFOlog level should be used in Business Logic to provide additional information between step and debug.BL_DEBUGlog level should be used in Business Logic for debug information for steps performed.MFD_STEPlog level should be used in MFDs to provide information on high level steps being performed.MFD_INFOlog level should be used in MFDs to provide additional information between step and debug.MFD_DEBUGlog level should be used in MFDs for debug information about steps performed and is preferred to MODULE_DEBUG.
Supported Level Groups
LevelGroup.BLincludes:BL_STEPBL_INFOBL_DEBUG
LevelGroup.MFDincludes:MFD_STEPMFD_INFOMFD_DEBUGMODULE_DEBUG
LevelGroup.TESTincludes:TEST_PASSTEST_FAILTEST_STEPTEST_INFOTEST_DEBUG
OS supported:
- LINUX
- WINDOWS
- ESXI
- FREEBSD
- EFI shell support
Issue reporting
If you encounter any bugs or have suggestions for improvements, you're welcome to contribute directly or open an issue here.
Metadata
Release files for mfd-common-libs 1.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mfd_common_libs-1.12.0-py3-none-any.whl | Python 3 | none | any | Details for mfd_common_libs-1.12.0-py3-none-any.whl |
Release files / mfd_common_libs-1.12.0-py3-none-any.whl
| Download URL | mfd_common_libs-1.12.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a6a1a91c8659295bc1ac0ed4d6188b552a25691def93304d17f955e42a98a62
|
|
BLAKE2b-256 checksum How to use checksums |
b70a74bbc7865e00b35211ef88ad5c01672450c5e930979eab16040a2a462702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for mfd-common-libs 1.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.