This commit is contained in:
WorldTeacher
2024-09-13 16:02:36 +02:00
parent a8c2277870
commit a071f70059
7 changed files with 369 additions and 5 deletions

111
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,111 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build LibrarySystem (Debug)",
"type": "shell",
"command": "pyinstaller",
"args": [
"--noconfirm",
"--onedir",
"--console",
"--icon",
"'${config:ApplicationIconPath}'",
"--name",
"LibrarySystem-debug",
"--contents-directory",
".",
"--clean",
"--add-data",
"'${config:configPath};config/'",
"--add-data",
"'${config:iconsPath};icons/'",
"'${workspaceFolder}/main_dev.py'"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new",
"focus": false
},
"dependsOn": "Compress dist Folder Debug",
"problemMatcher": "$pyinstaller"
},
{
"label": "Build LibrarySystem (Release)",
"type": "shell",
"command": "pyinstaller",
"args": [
"--noconfirm",
"--onedir",
"--windowed",
"--name",
"LibrarySystem",
"--contents-directory",
".",
"--clean",
"--add-data",
"'${config:configPath};config/'",
"--add-data",
"'${config:iconsPath};icons/'",
"--icon",
"'${config:ApplicationIconPath}'",
"'${workspaceFolder}/main.py'"
],
"group": {
"kind": "build",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "new",
"focus": false
},
"dependsOn": "Compress dist Folder Release",
"problemMatcher": "$pyinstaller"
},
{
"label": "Run LibrarySystem (live)",
"type": "shell",
"command": "c:/Users/aky547/GitHub/LibrarySystem/.venv/Scripts/python.exe",
"args": [
"'c:/Users/aky547/GitHub/LibrarySystem/main_dev.py'",
"--ic-logging"
],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": "$python"
},
{
"label": "Compress dist Folder Debug",
"type": "shell",
"command": "Compress-Archive",
"args": [
"-Path",
"${workspaceFolder}/dist/LibrarySystem-debug/",
"-DestinationPath",
"${workspaceFolder}/output/LibrarySystem-debug.zip",
],
"group": "build",
"presentation": "panel"
},
{
"label": "Compress dist Folder Release",
"type": "shell",
"command": "Compress-Archive",
"args": [
"-Path",
"${workspaceFolder}/dist/LibrarySystem/",
"-DestinationPath",
"${workspaceFolder}/output/LibrarySystem.zip",
],
"group": "build",
"presentation": "panel"
}
]
}

77
build.app.json Normal file
View File

@@ -0,0 +1,77 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "C:/Users/aky547/GitHub/LibrarySystem/main.py"
},
{
"optionDest": "onefile",
"value": false
},
{
"optionDest": "console",
"value": false
},
{
"optionDest": "icon_file",
"value": "C:/Users/aky547/Downloads/1490971308-map-icons-7_82746.ico"
},
{
"optionDest": "name",
"value": "LibrarySystem"
},
{
"optionDest": "contents_directory",
"value": "."
},
{
"optionDest": "clean_build",
"value": true
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "argv_emulation",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/config;config/"
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/icons;icons/"
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}

77
build.debug.app.json Normal file
View File

@@ -0,0 +1,77 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "C:/Users/aky547/GitHub/LibrarySystem/main_dev.py"
},
{
"optionDest": "onefile",
"value": false
},
{
"optionDest": "console",
"value": true
},
{
"optionDest": "icon_file",
"value": "C:/Users/aky547/Downloads/1490971308-map-icons-7_82746.ico"
},
{
"optionDest": "name",
"value": "LibrarySystem-debug"
},
{
"optionDest": "contents_directory",
"value": "."
},
{
"optionDest": "clean_build",
"value": true
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "argv_emulation",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/config;config/"
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/icons;icons/"
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}

77
build.release.app.json Normal file
View File

@@ -0,0 +1,77 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "C:/Users/aky547/GitHub/LibrarySystem/main.py"
},
{
"optionDest": "onefile",
"value": false
},
{
"optionDest": "console",
"value": false
},
{
"optionDest": "icon_file",
"value": "C:/Users/aky547/Downloads/1490971308-map-icons-7_82746.ico"
},
{
"optionDest": "name",
"value": "LibrarySystem"
},
{
"optionDest": "contents_directory",
"value": "."
},
{
"optionDest": "clean_build",
"value": true
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "argv_emulation",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/config;config/"
},
{
"optionDest": "datas",
"value": "C:/Users/aky547/GitHub/LibrarySystem/icons;icons/"
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}

View File

@@ -4,7 +4,7 @@ import omegaconf
class Config: class Config:
_config: Optional[omegaconf.DictConfig] = None _config: Optional[omegaconf.DictConfig] = None
def __init__(self, config_path: str): def __init__(self, config_path: str):
""" """
Loads the configuration file and stores it for future access. Loads the configuration file and stores it for future access.
@@ -94,17 +94,33 @@ class Config:
if self._config is None: if self._config is None:
raise RuntimeError("Configuration not loaded") raise RuntimeError("Configuration not loaded")
self._config.log_debug = value self._config.log_debug = value
@property
def ic_logging(self)->bool:
if self._config is None:
raise RuntimeError("Configuration not loaded")
return self._config.ic_logging
@ic_logging.setter
def ic_logging(self, value:bool):
if self._config is None:
raise RuntimeError("Configuration not loaded")
self._config.ic_logging = value
def save(self): def save(self):
if self._config is None: if self._config is None:
raise RuntimeError("Configuration not loaded") raise RuntimeError("Configuration not loaded")
omegaconf.OmegaConf.save(self._config, "config/settings.yaml") omegaconf.OmegaConf.save(self._config, "config/settings.yaml")
def apply_options(options:list):
if self._config is None:
raise RuntimeError("Configuration not loaded")
for option in options:
if option in self._config:
self._config[option] = True
else:
raise KeyError(f"Option {option} not found in configuration")
if __name__ == "__main__": if __name__ == "__main__":
cfg = Config("config/settings.yaml") cfg = Config("config/settings.yaml")
print(cfg.database.path) #print(cfg.database.path)
cfg.database.path = "nopathhere" cfg.database.path = "nopathhere"
print(cfg.database.path) #print(cfg.database.path)
cfg.save() cfg.save()
#cfg.updateValue("database.path", "Test") #cfg.updateValue("database.path", "Test")

View File

@@ -2,3 +2,4 @@ from src.ui.main_ui import launch
if __name__ == "__main__": if __name__ == "__main__":
launch() launch()

5
main_dev.py Normal file
View File

@@ -0,0 +1,5 @@
from src.ui.main_ui import launch
if __name__ == "__main__":
launch("--debug")