Skip to content

profile

Base process profilers

To import...

from dynamite_nsm.services.base import profile

BaseProcessProfiler

Process Profiler base class

__init__(self, install_directory, config_directory, required_install_files=(), required_config_files=()) special

Build a process profiler for a service

Parameters:

Name Type Description Default
install_directory

The directory where the service is installed

required
config_directory

The directory holding configuration related files

required
required_install_files

The names of files required to consider the installation successful

()
required_config_files

The names of config files to consider the installation properly configured.

()
Source code in dynamite_nsm/services/base/profile.py
def __init__(self, install_directory, config_directory, required_install_files=(),
             required_config_files=()):
    """Build a process profiler for a service
    Args:
        install_directory: The directory where the service is installed
        config_directory: The directory holding configuration related files
        required_install_files: The names of files required to consider the installation successful
        required_config_files: The names of config files to consider the installation properly configured.
    """
    if not utilities.is_setup():
        raise exceptions.DynamiteNotSetupError()
    self.install_directory = install_directory
    self.config_directory = config_directory
    self.required_install_files = required_install_files
    self.required_config_files = required_config_files

is_configured(self)

Determine if the instance is properly configured

Returns:

Type Description
bool

True if properly configured

Source code in dynamite_nsm/services/base/profile.py
def is_configured(self) -> bool:
    """Determine if the instance is properly configured

    Returns:
        True if properly configured
    """
    if not self.config_directory:
        return False
    if not os.path.exists(self.config_directory):
        return False
    for config_file in self.required_config_files:
        if config_file not in os.listdir(self.config_directory):
            return False
    return True

is_installed(self)

Determine if the instance is properly installed

Returns:

Type Description
bool

True if properly installed

Source code in dynamite_nsm/services/base/profile.py
def is_installed(self) -> bool:
    """Determine if the instance is properly installed

    Returns:
        True if properly installed
    """
    if not self.install_directory:
        return False
    if not os.path.exists(self.install_directory):
        return False
    for install_file in self.required_install_files:
        if install_file not in os.listdir(self.install_directory):
            return False
    return True