modules.config package

Submodules

modules.config.build_config module

class BuildCfg(build_config: str, json_path: str, load_json: bool = True)

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Holds a build tool configuration read from a JSON build tool configuration file.

fromReadJSON()

Converts the SimpleNamespace instance read from a JSON file to a BuildCfg instance to use.

writeJSON()

Writes the configuration to file (not used, because it is part of the project configuration JSON file).

classmethod fromReadJSON(instance: object)buildnis.modules.config.build_config.BuildCfg

Converts a SimpleNamespace instance load from a JSON build tools configuration file to a BuildCfg instance to use.

Parameters

instance (object) – The Simplenamespace instance to convert.

Returns

The data of the given object as a BuildCfg instance.

Return type

BuildCfg

initAttribs()None

Initializes the attributes that the build configuration object must have.

initStages()None

Sets all needed attributes of a stage.

writeJSON(json_path: str = '', to_ignore: Optional[List[str]] = None)None

Writes the generated config to disk.

Not used, because it is part of the project configuration file.

Parameters
  • json_path (str, optional) – The path to the JSON file to write to. Defaults to “”, this uses the saved path.

  • to_ignore (List[str]) – The list of attributes to ignore

modules.config.check module

class Check(os_name: str, arch: str, user_path: str, do_check: bool = True)

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Checks if all build tools are present.

Runs all build tool script_paths in configure_script_paths in the subdirectory with the name of the OS passed to the constructor.

Each build tool configuration (item of build_tool_cfgs) has the following attributes:

  • name The name of the build tool

  • name_long The full name of the build tool

  • version The version of the build tool, gathered from its output

  • version_arg The argument to call the build tool with to get the version

  • version_regex The regex to parse the output of version_arg to get

    version

  • build_tool_exe The executable’s file name

  • install_path The path to the executable

  • env_script The environment script to call before using the executable

  • env_script_arg The argument to call the environment script with

  • is_checked Has the executable been run and the version output been

    parsed?

os_name

the OS we are building for

Type

OSName

arch

the CPU architecture we are building for

Type

Arch

build_tool_cfgs

the list of build tool configurations returned from the script_paths in configure_script_paths/OS

Type

list

isBuildToolCfgOK()

checks if the build tool config has the minimum needed attributes

checkVersions()

runs all build tools with the version argument, to check if the executable works

checkVersions()None

Runs all configured build tools with the ‘show version’ argument.

To check, if the configured build tools exist and are working, try to execute each with the argument to get the version string of the build tool.

isBuildToolCfgOK(cfg: Any)bool

Checks if the given object has all the needed attributes of a build tool configuration.

Parameters

cfg (obj) – the object to check

Returns

True, if cfg has all needed attributes

False else

Return type

bool

runScript(script_path: pathlib.Path)None

Runs the script at the given path and saves it’s output.

Parameters

script_path (pathlib.Path) – The path to the script to run.

runScriptsInDir(working_dir: pathlib.Path)None

Runs all build tool config scripts in the given path.

Parameters

working_dir (pathlib.Path) – The path in which to run the build tool scripts.

searchBuildTool(name: str)object

Searches for a build tool with the given name.

Parameters

name (str) – The name of the build tool to search for.

Returns

The build tool object with the given name on success, None if not

found or another error occurred.

Return type

object

modules.config.config module

class Config(project_config: str, json_path: str)

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Loads all JSON configurations.

Parses the project’s JSON configuration, all module JSON configurations and all build tool JSON configurations.

Attributes: config_path (FilePath): the path to the project’s main JSON configuration. project_cfg_dir (FilePath): The directory part of config_path project_cfg (obj): the project’s JSON configuration stored in a Python class. module_cfgs (Dict[FilePath, Any]) the module JSON configurations

(mentioned in project_cfg)

build_cfgs (Dict[FilePath, Any]) the build JSON configurations

(mentioned in the module JSONs)

_logger (logging.Logger): the logger to use

Methods: parseModuleCfgs: Parses the module JSON configurations setup in the project

JSON

parseBuildCfgs: Parses the build JSON configurations setup in the module

JSONs

setHostConfigPath: Sets the path to the generated host config file setBuildToolCfgPath: Sets the path to the generated build tool config file setProjDepCfgPath: Sets the path to the generated project dependency config file getProjCfgDict: Get the project configuration as a JSON sequenceable dict

checkDependencies(force_check: bool = False)None

Calls the checkDependencies method of the project dependency configuration.

Parameters

force_check (bool, optional) – if this is True, check the dependency even if it has been checked before - if is_checked is True. Defaults to False.

connectInTarget(target: object)None

Connects the build configuration with the given target.

Parameters

target (object) – The target to search the build config for and connect it.

connectModulesBuildTools()None

For each target in each module: search for the build tool and put it into this module’s target.

expandAllPlaceholders(parents: Optional[List[object]] = None)None

Goes through all configurations and replaces placeholders in their elements. A Placeholder is a string like ${PLACEHOLDER}, a dollar sign followed by a curly opening brace, the string to replace and the closing curly brace.

Parameters

parents (List[object], optional) – The list of parent objects. Defaults to None.

parseBuildCfgs()None

Parses the build JSON configurations.

Parses all JSON build configurations in ./build_conf.

parseModuleCfgs()None

Parses the module JSON configurations.

Parses and stores all module JSON configurations configured in the project’s setup stored in self.project_cfg. Stores the configurations in module_cfgs.

readBuildCfgs()None

Reads the build configs from the generated JSON configuration. Rereads them if necessary.

readConfigsJSON()None

Reads all module and build configurations from their JSON files.

static readSingleTarget(target: object)None

Transforms the deserialized JSON object into a BuildCfg object. Rereads the original from disk if it has changed.

Parameters

target (object) – The read deserialized build config object.

searchBuildTools(build_tool_cfg: buildnis.modules.config.check.Check)None

Searches for a build tool in all found build tools. Connects it with a build configuration.

Parameters

build_tool_cfg (Check) – The build tools config to search for build tools.

searchInStage(build_tool_cfg: buildnis.modules.config.check.Check, stage: object)None

Searches for a build tool configured in a stage of a build configuration.

Parameters
  • build_tool_cfg (Check) – The build tool configuration to search in.

  • stage (object) – The stage containing the build tool name to search for.

setBuildToolCfgPath(path: str)None

Sets the path to the generated build tools config JSON file.

Parameters

path (FilePath) – the path to the build tools config file

setHostConfigPath(path: str)None

Sets the path to the generated host config JSON file.

Parameters

path (FilePath) – the path to the host config file

setProjDepCfgPath(path: str)None

Sets the path to the generated project dependency config JSON file.

Parameters

path (FilePath) – the path to the project dependency config file.

setProjectConstants()None

Sets the global project constants to be replaced by placeholders.

writeJSON(json_path: str = '', to_ignore=None)None

Writes the project’s config to a JSON file.

Parameters
  • json_path (FilePath, optional) – The path to the JSON file to write to. Defaults to “”, this uses the saved path.

  • to_ignore (list, optional) – List of attributes to ignore, to not save to disk. Defaults to [“project_dep_cfg”].

modules.config.config_dir_json module

class ConfigDirJson(file_name: str, working_dir: str, cfg_path: str = '')

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Class to handle the configuration of the directory all generated configuration files are written to.

file_name

The path to the JSON configuration file

Type

FilePath

cfg_path

The directory to save generated configurations to

Type

FilePath

writeJSON()

Writes the configuration directory configuration to a JSON file with path file_name.

writeJSON(json_path: str = '', to_ignore: Optional[List[str]] = None)None

Writes the path to the project config directory to a JSON file with the given path json_path.

Parameters

json_path (str, optional) –

The path to the JSON file to write to.

Defaults to “”, this uses the saved path.

to_ignore (List[str]): The list of attributes to ignore

modules.config.config_files module

class ConfigFiles(host_cfg: ConfigTuple, build_tools_cfg: ConfigTuple, project_dep_cfg: ConfigTuple, project_cfg: ConfigTuple)

Bases: NamedTuple

Holds the path and state of all JSON configuration files.

host_cfg

The host configuration, the path to the host configuration JSON file and its status.

Type

ConfigTuple

build_tools_Cfg

The build tools configuration JSON file path and its status.

Type

ConfigTuple

project_dep_cfg

The project dependency configuration JSON file path and its status.

Type

ConfigTuple

project_cfg

THe project configuration JSON file path and its status.

Type

ConfigTuple

build_tools_cfg: buildnis.modules.config.config_files.ConfigTuple

Alias for field number 1

host_cfg: buildnis.modules.config.config_files.ConfigTuple

Alias for field number 0

project_cfg: buildnis.modules.config.config_files.ConfigTuple

Alias for field number 3

project_dep_cfg: buildnis.modules.config.config_files.ConfigTuple

Alias for field number 2

class ConfigTuple(path: FilePath = '', exists: bool = False)

Bases: NamedTuple

Class to hold the path of a file and a bool that is True if the file already exists.

path

The path of the file.

Type

FilePath

exists

True`if the file already exists on disk, `False otherwise.

Type

bool

exists: bool

Alias for field number 1

path: str

Alias for field number 0

modules.config.config_values module

HOST_CPU_ARCH: str = ''

The host’s CPU architecture, like x64 or x86.

HOST_NAME: str = 'localhost'

The host’s name.

HOST_NUM_CORES: int = 1

The number of physical cores of the host’s CPU.

HOST_NUM_LOG_CORES: int = 1

The number of logical cores (including Hyperthreading) cores of this host’s CPU.

HOST_OS: str = ''

The OS we are running on.

PROJECT_AUTHOR: str = ''

The build project author’s name(s).

PROJECT_COMPANY: str = ''

The build project company’s name.

PROJECT_CONFIG_DIR_PATH: str = ''

The config path of the build project, the argument of –generated-conf-dir on the command line.

The build project’s copyright info string.

PROJECT_EMAIL: str = ''

The build project’s email address.

PROJECT_NAME: str = 'Build Project'

The build project’s name.

PROJECT_ROOT: str = './'

The root directory of the project, the directory project_config.json is located in.

PROJECT_VERSION: str = ''

The build project’s name.

PROJECT_WEB_URL: str = ''

The build project’s web URL.

modules.config.configure_build module

configureBuild(commandline_args: buildnis.modules.helpers.commandline_arguments.CommandlineArguments, logger: logging.Logger, config_dir_config: buildnis.modules.config.config_dir_json.ConfigDirJson, host_cfg: buildnis.modules.config.host.Host, host_cfg_filename: str, json_config_files: buildnis.modules.config.config_files.ConfigFiles)None

Configures the build.

Parameters
  • commandline_args (CommandlineArguments) – The object holding the command line arguments.

  • logger (logging.Logger) – The logger instance to use.

  • config_dir_config (ConfigDirJson) – The object holding the path to the directory, all generated JSON files are written to.

  • host_cfg (Host) – The host configuration instance.

  • host_cfg_filename (FilePath) – Path to the host configuration JSON file to write.

  • json_config_files (ConfigFiles) – Holds paths to all JSON configuration files to write.

ifConfigureDeleteProjectJSON(commandline_args: buildnis.modules.helpers.commandline_arguments.CommandlineArguments, logger: logging.Logger, json_config_files: buildnis.modules.config.config_files.ConfigFiles)None

Deletes the project configuration JSON if it exists and –configure has been called.

Parameters
  • commandline_args (CommandlineArguments) – The object holding the command line arguments

  • logger (logging.Logger) – THe logger to use.

  • json_config_files (ConfigFiles) – The path to the project configuration JSON and whether it exists.

setupProjectCfg(commandline_args: buildnis.modules.helpers.commandline_arguments.CommandlineArguments, json_config_files: buildnis.modules.config.config_files.ConfigFiles)buildnis.modules.config.config.Config

Sets up the project configuration, including the project dependency configuration.

Parameters
  • commandline_args (CommandlineArguments) – The object holding all command line arguments.

  • json_config_files (ConfigFiles) – Holds the path to the project configuration JSON file’s path.

Returns

The project config containing all values

Return type

Config

writeBuildTools(commandline_args: buildnis.modules.helpers.commandline_arguments.CommandlineArguments, logger: logging.Logger, host_cfg: buildnis.modules.config.host.Host, json_config_files: buildnis.modules.config.config_files.ConfigFiles)buildnis.modules.config.check.Check

Writes the build tools configuration to disk.

Parameters
  • commandline_args (CommandlineArguments) – The object holding all command line arguments.

  • logger (logging.Logger) – The logger to use.

  • host_cfg (Host) – The host configuration instance.

  • json_config_files (ConfigFiles) – Holds the Path to the build tools JSON configuration path, the path to write to.

Returns

The build tools configuration object to use.

Return type

Check

writeHostCfg(host_cfg: buildnis.modules.config.host.Host, host_cfg_filename: str)None

Write the host configuration JSON file.

Parameters
  • host_cfg (Host) – The host configuration to save.

  • host_cfg_filename (FilePath) – The path of the JSON file to write to.

writeProjectJSON(host_cfg_filename: str, json_config_files: buildnis.modules.config.config_files.ConfigFiles, cfg: buildnis.modules.config.config.Config)None

Writes the project configuration JSON to disk.

Parameters
  • host_cfg_filename (FilePath) – Path to the host configuration.

  • json_config_files (ConfigFiles) – The object holding the path to the project configuration JSON to write.

  • cfg (Config) – The project configuration instance to write to disk.

modules.config.host module

class Host

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Holds all information about the host this is running on.

Stores hostname, OS, OS version, CPU architecture, RAM, CPU name, …

Attributes

host_name (str): This host’s name os (str): The OS this is running on (like “Windows”, “Linux”) os_vers_major (str): Major version of the OS (like “10” for Windows 10) os_vers (str): Excact version string cpu_arch (str): CPU architecture, like “x64” or “x86” cpu (str): The detailed name of the CPU file_name (str): The JSON identifier of the host config file, part

of the file name

level2_cache (int): Size of the CPU’s level 2 cache, in bytes level3_cache (int): Size of the CPU’s level 3 cache, in bytes num_cores (int): The number of physical cores num_logical_cores (int): The number of logical, ‘virtual’ cores ram_total (int): Amount of physical RAM in bytes gpu List[str]: The list of names of all GPUs python_version (str): The version of this host’s Python interpreter json_path(str): The path to the written JSON host config file

Methods
collectWindowsConfig: adds information, that has to be collected in a

Windows specific way

collectLinuxConfig: adds information, that has to be collected in a

Linux specific way

collectOSXConfig: adds information, that has to be collected in a

Mac OS X specific way

GetCPUInfo()None

Gets the CPU info, like cache sizes, number of cores.

collectLinuxConfig()None

Collect information about the hardware we’re running on on Linux.

Calls the following commands:

cat /etc/os-release NAME=”Red Hat Enterprise Linux” VERSION=”8.3 (Ootpa)”

grep “model name” /proc/cpuinfo |uniq|cut -d’:’ -f2 getconf -a|grep LEVEL2_CACHE_SIZE|awk ‘{print $2}’ getconf -a|grep LEVEL3_CACHE_SIZE|awk ‘{print $2}’ grep “cpu cores” /proc/cpuinfo |uniq|cut -d’:’ -f2 grep “siblings” /proc/cpuinfo |uniq |cut -d’:’ -f2 free -b|grep “Mem:”|awk ‘{print $2}’ grep “DISTRIB_DESCRIPTION” /etc/lsb-release lspci|grep VGA|cut -f3 -d’:’

collectLinuxCpuGpuRam()

Collects information about this host’s CPU, GPU, and so on on Linux.

collectOSXConfig()None

Collect information about the hardware we’re running on on MacOS X.

Using this commands: sysctl -n hw.memsize sysctl -n hw.physicalcpu sysctl -n hw.logicalcpu sysctl -n hw.l2cachesize sysctl -n hw.l3cachesize sysctl -n machdep.cpu.brand_string sw_vers -productVersion

TODO get GPU info: system_profiler SPDisplaysDataType

collectWinCpuGpuRam()

Collects the Windows CPU, GPU and RAM size information.

collectWindowsConfig()None

Collect information about the hardware we’re running on on Windows.

Calls these commands and parses their outputs:

wmic cpu get L2CacheSize,L3CacheSize,NumberOfLogicalProcessors,

NumberOfCores,Name

wmic memorychip get capacity wmic path win32_VideoController get name

getCPU()None

Sets the CPU name.

getGPU()None

Sets the GPU name list.

getGPULspci()None

Gets the GPU names using /sbin/lspci.

getGPUNamesLinux()None

Gets the list of GPU names.

getGPUSbinLspci()None

Gets the GPU names using lspci.

getOSInfo()None

Gets Info about the OS, like Name, CPU architecture, and similar.

getRAM()None

Sets the RAM size.

parseCPUInfoLine(line: str)None

Parses the output of the CPU info wmic command.

Parameters

line (str) – The line of output to parse.

parseRAMline(line: str)None

Parses a single line of output to get the RAM size.

Parameters

line (str) – The line of output to parse.

retryCPUInfo(line: str)None

Retry getting the CPU info, this time ignore L2Cache (GitHub Windows runners doesn’t display L2 cache).

Parameters

line (str) – The line of output to parse.

setConstants()None

Set the host constants to use for configuration files.

printHostInfo()None

To test the collection of the host’s information, print all to stdout.

modules.config.host_linux module

getCPUNameLinux()buildnis.modules.config.CmdOutput

Returns the CPU’s name.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getGPUNamesLinux()buildnis.modules.config.CmdOutput

Returns the names of the GPUs.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getGPUNamesSbinLinux()buildnis.modules.config.CmdOutput

Returns the names of the GPUs, using /sbin/lspci because some distributions don’t have lspci in /usr/bin

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getL2CacheLinux()buildnis.modules.config.CmdOutput

Returns the size of the CPU’s level 2 cache.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getL3CacheLinux()buildnis.modules.config.CmdOutput

Returns the size of the CPU’s level 3 cache.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getNumCoresLinux()buildnis.modules.config.CmdOutput

Returns the number of physical cores.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getNumLogCoresLinux()buildnis.modules.config.CmdOutput

Returns the number of logical cores, including the hyperthreading.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getOSMajVers()buildnis.modules.config.CmdOutput

Returns the major OS version.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getOSVer()buildnis.modules.config.CmdOutput

Returns the minor OS version.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getRAMSizeLinux()buildnis.modules.config.CmdOutput

Returns the RAM size in bytes.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

modules.config.host_osx module

getCPUNameOSX()buildnis.modules.config.CmdOutput

Returns the CPU name.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getGPUOSX()buildnis.modules.config.CmdOutput

Return the GPU names.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getL2CacheOSX()buildnis.modules.config.CmdOutput

Returns the size of the CPU’s level 2 cache.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getL3CacheOSX()buildnis.modules.config.CmdOutput

Returns the size of the CPU’s level 3 cache.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getNumCoresOSX()buildnis.modules.config.CmdOutput

Returns the number of physical cores.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getNumLogCoresOSX()buildnis.modules.config.CmdOutput

Returns the number of logical cores, including hyperthreading.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getOSName()buildnis.modules.config.CmdOutput

Returns the OS version of OS X.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getRAMSizeOSX()buildnis.modules.config.CmdOutput

Returns the RAM size in bytes.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

modules.config.host_windows module

getCPUInfo()buildnis.modules.config.CmdOutput

Gets CPU info using wmic.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getCPUName()buildnis.modules.config.CmdOutput

Gets the CPU name using wmic

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getGPUInfo()buildnis.modules.config.CmdOutput

Returns the GPU names.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

getMemInfo()buildnis.modules.config.CmdOutput

Returns the RAM size in bytes.

Returns

The output of the command, as a CmdOutput instance containing

stdout and stderr as attributes.

Return type

CmdOutput

modules.config.json_base_class module

class JSONBaseClass(config_file_name: str, config_name: str)

Bases: object

Base class for all objects that read and/or write JSON configuration files. Holds the values of the JSON file in it’S attributes (all except _logger, the loggin.Logger instance).

hasConfigChangedOnDisk()

Returns True if the JSON configuration has changed since the time the checksum has been calculated.

expandAllPlaceholders()

Replaces all placeholders (like ${PLACEHOLDER}) in the instance’s attribute values.

readJSON()

Reads the JSON config file and saves the values to attributes.

reReadIfChangedOnDisk()

Checks if the original read file has changed on disk, and if yes, rereads the file from disk.

writeJSON()

Writes the attributes and their values to the JSON file.

reWriteIfChangedOnDisk()

Checks if the original read file has changed on disk, and if yes, rereads the file from disk and rewrites it to the generated JSON’s file path.

addAttributesIfNotExist(attributes: Dict[str, object])None

Adds each attribute in the given dictionary of attributes.

The key of the dictionary is the attribute’s name, the value the deault value to set the attribute to, if it didn’t exist.

Parameters

attributes (Dict[str, object]) – The dictionary of attributes and default values

expandAllPlaceholders(parents: Optional[List[object]] = None)None

Goes through all configurations and replaces placeholders in their elements. A Placeholder is a string like ${PLACEHOLDER}, a dollar sign followed by a curly opening brace, the string to replace and the closing curly brace.

See also: modules.helpers.config_parser.parseConfigElement

Parameters

parents (List[object]) – The hierarchical list of parent objects.

hasConfigChangedOnDisk()bool

Returns True if the JSON file has been changed since the time the checksum has been calculated.

Returns

True if the original JSON file has changed since the time

the file’s checksum has been saved.

False else

Return type

bool

reReadIfChangedOnDisk()None

Checks if the JSON configuration file has been changed since the time the checksum has been calculated, if yes, it is reread from disk.

reWriteIfChangedOnDisk()None

Checks if the JSON configuration file has been changed since the time the checksum has been calculated, if yes, it is reread from disk and the generated JSON file is written to it’s file path.

readJSON(json_path: str)None

Reads a JSON file and puts it’s items into attributes of this object.

Parameters

json_path (FilePath) – The path of the JSON file to load.

writeJSON(json_path: str, to_ignore: Optional[List[str]] = None)None

Writes the class instance to the JSON file.

Parameters
  • json_path (FilePath) – The path to the file to write the JSON to

  • to_ignore (List[str]) – The list of attributes to ignore

setAttrIfNotExist(instance: object, attributes: Dict[str, object])None

Check if the given object has each of the given attributes, if not, set it to the given value.

Parameters
  • instance (object) – The instance to check for attributes.

  • attributes (Dict[str, object]) – The dictionary of attributes and attribute values.

modules.config.module module

class ModuleCfg(module_config: str, json_path: str, load_json: bool = True)

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Holds a single module configuration read from a JSON module configuration file.

fromReadJSON()

Converts the SimpleNamespace instance read from a JSON file to a ModuleCfg instance to use.

writeJSON()

Writes the configuration to file (not used, because it is part of the project configuration JSON file).

classmethod fromReadJSON(instance: object)buildnis.modules.config.module.ModuleCfg

Converts a SimpleNamespace instance load from a JSON module configuration file to a ModuleCfg instance to use.

Parameters

instance (object) – The Simplenamespace instance to convert.

Returns

The data of the given object as a ModuleCfg instance.

Return type

ModuleCfg

writeJSON(json_path: str = '', to_ignore: Optional[List[str]] = None)None

Writes the generated config to disk.

Not used, because it is part of the project configuration file.

Parameters
  • json_path (FilePath, optional) – The path to the JSON file to write to. Defaults to “”, this uses the saved path.

  • to_ignore (List[str]) – The list of attributes to ignore.

modules.config.project_dependency module

class ProjectDependency(dependency_config: str, json_path: str)

Bases: buildnis.modules.config.json_base_class.JSONBaseClass

Parses the project dependency configuration file and checks the dependencies.

Parses the project dependency JSON file and saves the config file to dependency_cfg. Checks the dependencies and tries to download and install missing dependencies. Writes the altered configuration to the JSON file.

config_path

Path to the project dependency JSON file

Type

FilePath

dependencies

The list of dependencies

Type

List[object]

Dependency object attributes
name

the dependency’s name

Type

str

website_url

website to get information about the dependency

Type

str

download_url

website to download the dependency

Type

str

download_dir

path to the directory to download the dependency to

Type

str

install_cmd

command line to call to install the dependency

Type

str

install_arguments

arguments to pass to the install command

Type

List[str]

ok_if_exists

if this file exists, the dependency has been successfully installed

Type

FilePath

ok_if_executable

if this file is executable, the dependency has been successfully installed

Type

FilePath

executable_argument

the argument to call ok_if_executable with to test it

Type

str

executable_check_regex

the regex to parse the output of ok_if_executable with. If a match is found, the dependency has been successfully installed

Type

str

is_checked

if this is true, the dependency has been successfully installed

Type

bool

checkDependencies()

Checks all dependencies in the list of dependencies dependencies, if the dependency is installed.

isDependencyFulfilled()

Returns `True`if the dependency has been installed.

installDep()

Installs the given dependency.

isExecuteableDep()

Checks, if the given dependency’s executable works, that is, returns the expected string.

checkDependencies(force_check: bool = False)None

Runs all configured dependency checks.

Checks for each dependency if the configured file exists or the configured executable works. If not, it tries to download and/or install the dependency and tries again.

Parameters

force_check (bool, optional) – if this is True, check the dependency even if it has been checked before - if is_checked is True. Defaults to False.

checkIFInstalled(dep: object)None

Check if the dependency is installed, if not, install it and check again.

Parameters

dep (object) – The dependency object to check.

download(dep: object)None

Download the dependency.

Parameters

dep (object) – The dependency object to download.

install(dep: object)None

Install the dependency.

Parameters

dep (object) – The dependency object to install.

installDep(dep: object)None

Download and/or install the given dependency.

Parameters

dep (object) – the dependency to install or download

isDependencyFulfilled(dep: object)bool

Checks if the given dependency is installed.

Checks if the configured path exist or the configured executable works.

Parameters

dep (object) – the dependency object to check

Returns

True, if the dependency has been found

False else

Return type

bool

isExecuteableDep(dep: object)bool

Execute the dependency, if that works, returns True.

Parameters

dep (object) – the dependency to run

Returns

True if the executable has been running OK and returns the

configured string.

False else

Return type

bool

okIfExecutable(dep: object)bool

Check if the executable of the object is executable, that is, exists and generates output.

Parameters

dep (object) – The object to check if it’S configured executable is actually executable.

Returns

True, if the configured executable is callable, False else.

Return type

bool

okIfExists(dep: object)bool

Check if the dependency is installed by checking the existence of a path.

Parameters

dep (object) – The object to check if it is installed.

Returns

True, if the path exists, False else.

Return type

bool

static setMustHaveAttribs(dep: object)None

Sets the attributes a dependency object instance must have.

Parameters

dep (object) – The object to check for must-have attributes.

writeJSON(json_path: str = '', to_ignore: Optional[List[str]] = None)None

Writes the generated dependency configuration to disk.

Parameters
  • json_path (FilePath, optional) – The path to the JSON file to write to. Defaults to “”, this uses the saved path.

  • to_ignore (List[str]) – The list of attributes to ignore.

Module contents

Arch

alias of str

class CmdOutput(std_out: str = '', err_out: str = '')

Bases: NamedTuple

The return type of executed commands.

std_out

the stdout output of the executed command

Type

str

err_out

the stderr output of the executed command

Type

str

err_out: str

Alias for field number 1

std_out: str

Alias for field number 0

class ConfigVersion(major: str = '', minor: str = '')

Bases: NamedTuple

The version of a JSON configuration file.

major: str

Alias for field number 0

minor: str

Alias for field number 1

FilePath

alias of str

OSName

alias of str