mylinux.model.config package

Submodules

mylinux.model.config.Info module

class mylinux.model.config.Info.Info(path)[source]

Class for project info.json file

Parameters:

path (str) – Path to the info.json file.

Variables:
  • __path (str) – See args...
  • __data (dic) – Data from info file on __path.
  • __requiredDataKeys (arr-str) – What dic keys info file should have.
Other Parameters:
 

Update __data with info data.

requiredDataKeys = ['info', 'class', 'module']
__call__()[source]
Returns:__data
__getitem__(item)[source]
Parameters:(str) (item) –
Returns:__data[item]
path
Returns:__path
update()[source]

Checking and updating __data with new data

Other Parameters:
 
  • Check if file on __path exist.
  • Check if json on __path is correct.
  • If pre check fails show error report.
_Info__requiredDataKeys = ['info', 'class', 'module']

mylinux.model.config.Installed module

class mylinux.model.config.Installed.Installed(path)[source]

Class for handeling installed file.

Parameters:

path (str) – Absolute path to installed file.

Variables:
  • __inited (boo) – Was class allready inited?
  • __selectTableRule (str) – Define CSV like decision table rule for selecting packages.
  • __executeTableRule (str) – Define CSV like decision table rule for executing packages.
  • __selectTable (cla) – DecisionTable class activated with select table rule.
  • __executeTable (cla) – DecisionTable class activated with execute table rule.
  • __requirdPackageKeys (arr-str) – Required packages keys in every package which is installed.
  • __path (str) – See args info.
  • __data (dic) – All installed data.
Raises:

AppErr.developer – If class was already inited.

Other Parameters:
 

Set data to __data.

Note

Installed class for every package executing/selecting action is using decisionTable package which makes logic visual more nice than raw if/else/elif code...

For more info visit: https://decisiontable.readthedocs.org

__call__()[source]
Returns:__data
__getitem__(item)[source]
Parameters:(str) (item) –
Returns:__data[item]
path
Returns:__path
selectTableRule
Returns:__selectTableRule
executeTableRule
Returns:__executeTableRule
requiredPackageKeys
Returns:__requiredPackageKeys
getNames()[source]

Get packages names from installed

Returns:Array of str. of installed packages.
packageAfterExecution(packageName, err_package, err_config, stdout='', stderr='')[source]

Set package in installed new set of data

Parameters:
  • packageName (str) – Package which states will be updated.
  • err_package (str) – Does have package after execution error?
  • err_config (str) – Does config have execution error?
  • stdout (str) – Stout from execution.
  • stderr (str) – Possible error message from terminal.
Other Parameters:
 
  • Get package and config state base on execution information.
  • Update package in installed with new set of data.
decidePackageExecution(packageName)[source]

Decide what action should be executed on package.

Parameters:packageName (str) – Package name
Returns:[package state executing decision, config -//- decision]
getStates(key, packageNames, filler)[source]

Hellper method for TUI select class.

Get infos data value from all installed package key. If package is not installed replace states with filler.

Parameters:
  • key (str) – Package key from installed package data.
  • packageNames (arr-str) – All package names so that key value is extracted.
  • filler (str) – If package is not in installed replace value with this.
Returns:

If not packageNames return arr-str of all key values from installed packages data. If packageNames return arr-str of all selected package key values from installed packages data.

createOrUpdateSelected(config, action, packageNames)[source]

Method for creation or updating installed packages data.

If package in installed exist it will update its data. Else the package will be created.

Parameters:
  • config (boo) – Is action want to be executed on configs too?
  • action (str) – What action will be made on packageNames?
  • packageNames (arr-str) – What packages names should be executed with an action?
Other Parameters:
 
  • If package do not exist in installed create one with None package state and None config state.
  • If package do not exist but don’t have right action show error report.
  • Make select decision for package base on action and config boolean value.
  • If right decision was not finded show hinting report.
  • If decision was finded change package values.
override()[source]

Update or override __data variable

Other Parameters:
 
  • Check if file on __path exist.
  • Check if json format is ok.
  • If pre checks fail show error report.
_Installed__changePackageValues(packageName, **args)

Handler for updating packages data.

Parameters:
  • packageName (str) – Package name whose values are going to change.
  • **args – Keys and values for package data.
Other Parameters:
 
  • Check if key in args is permited to be changed.
  • If check fails show error report.
  • Set key data to new value from args.
  • Update last change value in package.
_Installed__createPackage(packageName)

Create new installed package.

Parameters:

packageName (str) – Name for new package.

Other Parameters:
 
  • Check if packageName don’t exist in installed.
  • If pre check fails show error report.
  • Create new package in installed.
_Installed__executeTable = <decisionTable.DecisionTable.DecisionTable object>
_Installed__executeTableRule = '\n\t\tpackageState configState execute err_package err_config new_packageState new_configState\n\t\t===============================================================================================================\n\t\tinstall install installAll False False ok ok\n\t\t. . . . True ok error\n\t\t. . . True None error install\n\t\tpurge purge purgeAll False False None None\n\t\t. . . False True None error\n\t\t. . . True None error purge\n\t\tok purge purgeConfig None True ok error\n\t\t. . . None False ok None\n\t\tok update updateConfig None False ok ok\n\t\t. . . None True ok error\n\t\tok install installConfig None False ok ok\n\t\t. . . None True ok error\n\t\tNone purge purgeConfig None False None None\n\t\t. . . None True None error'
_Installed__inited = False
_Installed__requiredPackageKeys = ['created', 'configState', 'stdout', 'lastChange', 'stderr', 'packageState']
_Installed__selectTable = <decisionTable.DecisionTable.DecisionTable object>
_Installed__selectTableRule = '\n\t\tpackageState configState config action new_packageState new_configState\n\t\t================================================================================================\n\t\tNone None False install install install\n\t\tok ok False purge purge purge\n\t\t. . True purge ok purge\n\t\t. . True update ok update\n\t\tok error False purge purge purge\n\t\t. . True update ok update\n\t\t. . True install ok install\n\t\t. . True purge ok purge\n\t\terror install False purge purge purge\n\t\t. . False install install install\n\t\tNone error True purge None purge\n\t\terror purge False purge purge purge\n\t\tok None True install ok install\n\t\t. . False purge purge purge\n\t\t* * * * ERROR ERROR'
_Installed__setData()

Seting installed data.

Other Parameters:
 
  • Check if file on __path exist.
  • Check if json format is correct.
  • If pre checks fails show error report.
  • Set __data with data from __path.

mylinux.model.config.Package module

class mylinux.model.config.Package.Package(name, path)[source]

Class for handeling all package data.

Parameters:
  • name (str) – Package name.
  • path (str) – Absolute path to the package folder.
Variables:
  • __requiredScriptNames (str) – What scripts must package scripts folder have?
  • __relScriptsPath (str) – Relative path to the scripts folder.
  • __relInfoPath (str) – Relative path to the info package file.
  • __name (str) – Name of the package.
  • __path (str) – See args info.
  • __info (cls) – Info class instance.
  • __scripts (arr-cls) – Every package script instances.
requiredScriptNames = ['config-install', 'config-purge', 'package-install', 'package-purge', 'test.py']
relScriptsPath = '/scripts'
relInfoPath = '/info.json'
scriptsPath
Returns:Absolute scripts path
infoPath
Returns:Absolute info path
name
Returns:__name
path
Returns:__path
info
Returns:__info
scripts
Returns:__scripts
getScript(name)[source]
Parameters:

name (str) – Script name

Returns:

Script instance

Other Parameters:
 
  • Check if script name match.
  • If check fails show error report.
_Package__relInfoPath = '/info.json'
_Package__relScriptsPath = '/scripts'
_Package__requiredScriptNames = ['config-install', 'config-purge', 'package-install', 'package-purge', 'test.py']
_Package__setInfo()

Set __info variable with Info class instance.

_Package__setScripts()

Set __scripts variable with all Scripts class instance.

Other Parameters:
 
  • Get all scripts file names in scripts path.
  • Check if every script name is inrequired Script variable.
  • If pre check fails show error report.
  • Fill __scripts variable with Script instances.

mylinux.model.config.Script module

class mylinux.model.config.Script.Script(name, path)[source]

Class for handeling scripts data etc...

Parameters:
  • name (str) – Name of the script.
  • path (str) – Absolute path to the scirpt.
Variables:
  • __data (str) – All data from file on path.
  • __name (str) – Name of the script.
  • __path (str) – Absolute path to the script.
  • __cmdArrays (arr-arr-str) – Script commands.
Other Parameters:
 

Update __data and __cmdArrays variables.

__call__()[source]
Returns:__data
name
Returns:__name
path
Returns:__path
cmdArrays
Returns:__cmdArrays
update()[source]

Update __data and __cmdArrays

Other Parameters:
 
  • Check if file exist on __path.
  • If check fails show error report.
  • Set __data variable.
  • Split file on lines.
  • Split every line on words.
  • Set __cmdArrays variable.

Module contents

Other Parameters:
 
  • module_Info (mod)
  • module_Installed (mod)
  • module_Package (mod)
  • module_Script (mod)
  • Script (cla)
  • Package (cla)
  • Installed (cla)
  • Info (cla)