-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve env vars handling #54
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,15 +68,9 @@ def get_ovos_config(): | |
from ovos_utils.system import is_running_from_module | ||
|
||
# populate default values | ||
config = {"xdg": True, | ||
"base_folder": os.environ.get("OVOS_CONFIG_BASE_FOLDER") or | ||
"mycroft", | ||
"config_filename": os.environ.get("OVOS_CONFIG_FILENAME") or | ||
"mycroft.conf"} | ||
try: | ||
config["default_config_path"] = _oloc.find_default_config() | ||
except FileNotFoundError: # not a mycroft device | ||
config["default_config_path"] = join(dirname(__file__), "mycroft.conf") | ||
config = {"base_folder": os.environ.get("OVOS_CONFIG_BASE_FOLDER") or "mycroft", | ||
"config_filename": os.environ.get("OVOS_CONFIG_FILENAME") or "mycroft.conf", | ||
"default_config_path": os.environ.get("OVOS_DEFAULT_CONFIG") or f"{dirname(__file__)}/mycroft.conf"} | ||
|
||
# load ovos.conf | ||
for path in get_ovos_default_config_paths(): | ||
|
@@ -164,6 +158,7 @@ def set_xdg_base(folder_name): | |
NOTE: this value will be set globally, per core overrides in ovos.conf take precedence | ||
""" | ||
LOG.info(f"XDG base folder set to: '{folder_name}'") | ||
os.environ["OVOS_CONFIG_BASE_FOLDER"] = folder_name | ||
save_ovos_config({"base_folder": folder_name}) | ||
|
||
|
||
|
@@ -178,6 +173,7 @@ def set_config_filename(file_name, core_folder=None): | |
if core_folder: | ||
set_xdg_base(core_folder) | ||
LOG.info(f"config filename set to: '{file_name}'") | ||
os.environ["OVOS_CONFIG_FILENAME"] = folder_name | ||
JarbasAl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
save_ovos_config({"config_filename": file_name}) | ||
|
||
|
||
|
@@ -190,14 +186,14 @@ def get_config_filename(): | |
return get_ovos_config().get("config_filename") or "mycroft.conf" | ||
|
||
|
||
def set_default_config(file_path=None): | ||
def set_default_config(file_path=f"{dirname(__file__)}/mycroft.conf"): | ||
""" full path to default config file to be used | ||
NOTE: this is a full path, not a directory! "config_filename" parameter is not used here | ||
|
||
different derivative cores may change this file, this value is derived from ovos.conf | ||
|
||
NOTE: this value will be set globally, per core overrides in ovos.conf take precedence | ||
""" | ||
file_path = file_path or _oloc.find_default_config() | ||
LOG.info(f"default config file changed to: {file_path}") | ||
os.environ["OVOS_DEFAULT_CONFIG"] = file_path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will need to look into side effects here since |
||
save_ovos_config({"default_config_path": file_path}) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to look into side effects here since
os.env
could affect code outside of this module?