enable flexible folder creation for addon (e.g. /share/emhass)#655
Closed
mime24 wants to merge 3 commits intodavidusb-geek:masterfrom
Closed
enable flexible folder creation for addon (e.g. /share/emhass)#655mime24 wants to merge 3 commits intodavidusb-geek:masterfrom
mime24 wants to merge 3 commits intodavidusb-geek:masterfrom
Conversation
* create data path handed over via options.json * new try * work with try ald exept * fix formating * fix formatting * fix formatting * Exception Error message --------- Co-authored-by: Michael Metz <michael.metz@siemens.com>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR changes how the add-on resolves and prepares its data_path: instead of only using an existing path from options, it now attempts to create the directory, logs a warning on failure, and conditionally updates the configuration, laying groundwork for using paths like /share/emhass. Sequence diagram for updated data_path handling in build_secretssequenceDiagram
actor User
participant AddonRuntime
participant utils_build_secrets as utils_build_secrets
participant Pathlib as pathlib_Path
participant Logger as logger
User ->> AddonRuntime: start_addon_with_options
AddonRuntime ->> utils_build_secrets: build_secrets(options, emhass_conf, ...)
utils_build_secrets ->> utils_build_secrets: read options data_path
alt data_path is not None
utils_build_secrets ->> Pathlib: Path(options_data_path)
activate Pathlib
Pathlib -->> utils_build_secrets: data_path_object
deactivate Pathlib
utils_build_secrets ->> Pathlib: data_path_object.mkdir(parents=False, exist_ok=True)
alt mkdir succeeds
utils_build_secrets ->> utils_build_secrets: emhass_conf data_path = data_path_object
else mkdir raises Exception
utils_build_secrets ->> Logger: warning(cannot create data_path directory...)
Logger -->> utils_build_secrets: done
utils_build_secrets ->> utils_build_secrets: keep default emhass_conf data_path
end
else data_path is None
utils_build_secrets ->> utils_build_secrets: keep default emhass_conf data_path
end
utils_build_secrets -->> AddonRuntime: updated emhass_conf
AddonRuntime -->> User: addon running with resolved data_path
Flow diagram for data_path directory creation logicflowchart TD
A[start_build_secrets] --> B{options_data_path_is_not_None}
B -- Yes --> C["Create Path object from options data_path"]
C --> D["Call mkdir on Path with parents=False and exist_ok=True"]
D --> E{mkdir_raises_exception}
E -- No --> F["Set emhass_conf data_path to created Path"]
F --> G[end_build_secrets]
E -- Yes --> H["Log warning via logger and keep default emhass_conf data_path"]
H --> G
B -- No --> I["Skip override and keep default emhass_conf data_path"]
I --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #655 +/- ##
=======================================
Coverage 77.95% 77.95%
=======================================
Files 10 10
Lines 5057 5062 +5
=======================================
+ Hits 3942 3946 +4
- Misses 1115 1116 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* create data path handed over via options.json * new try * work with try ald exept * fix formating * fix formatting * fix formatting * Exception Error message --------- Co-authored-by: Michael Metz <michael.metz@siemens.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



With this pull request, we are laying the foundation for enabling the data path /share/emhass in the add-on.
The path specified in the options is checked and any missing subfolders are created.
This is a prerequisite for the adjustment in the add-on. refer to davidusb-geek/emhass-add-on#122
Summary by Sourcery
Enhancements: