config: add config.runtime.uid

This commit is contained in:
InsanePrawn 2022-08-27 03:49:07 +02:00
parent 4c77a16bba
commit 6b64989a3b
2 changed files with 11 additions and 7 deletions

View file

@ -200,11 +200,12 @@ class Config(DataClass):
@munchclass()
class RuntimeConfiguration(DataClass):
verbose: bool
config_file: Optional[str]
arch: Optional[Arch]
no_wrap: bool
script_source_dir: str
error_shell: bool
config_file: Optional[str]
script_source_dir: Optional[str]
arch: Optional[Arch]
uid: Optional[int]
class ConfigLoadState(DataClass):

View file

@ -53,11 +53,12 @@ CONFIG_SECTIONS = list(CONFIG_DEFAULTS.keys())
CONFIG_RUNTIME_DEFAULTS: RuntimeConfiguration = RuntimeConfiguration.fromDict({
'verbose': False,
'config_file': None,
'arch': None,
'no_wrap': False,
'script_source_dir': os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
'error_shell': False,
'config_file': None,
'script_source_dir': None,
'arch': None,
'uid': None,
})
@ -194,7 +195,9 @@ class ConfigStateHolder:
self.file = Config.fromDict(merge_configs(conf_new=file_conf_base, conf_base=CONFIG_DEFAULTS))
self.file_state = ConfigLoadState()
self.runtime = RuntimeConfiguration.fromDict(CONFIG_RUNTIME_DEFAULTS | runtime_conf)
self.runtime['arch'] = os.uname().machine
self.runtime.arch = os.uname().machine
self.runtime.script_source_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
self.runtime.uid = os.getuid()
self._profile_cache = {}
if file_conf_path:
self.try_load_file(file_conf_path)