aboutsummaryrefslogtreecommitdiffstats
path: root/agl_service_voiceagent/utils/config.py
diff options
context:
space:
mode:
authorMalik Talha <talhamalik727x@gmail.com>2023-10-29 20:52:29 +0500
committerMalik Talha <talhamalik727x@gmail.com>2023-10-29 20:52:29 +0500
commit42a03d2550f60a8064078f19a743afb944f9ff69 (patch)
treec9a7b3d028737d5fecd2e05f69e1c744810ed5fb /agl_service_voiceagent/utils/config.py
parenta10c988b5480ca5b937a2793b450cfa01f569d76 (diff)
Update voice agent service
Add new features such as an option to load service using an external config file, enhanced kuksa client, and a more robust mapper. Signed-off-by: Malik Talha <talhamalik727x@gmail.com> Change-Id: Iba3cfd234c0aabad67b293669d456bb73d8e3135
Diffstat (limited to 'agl_service_voiceagent/utils/config.py')
-rw-r--r--agl_service_voiceagent/utils/config.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/agl_service_voiceagent/utils/config.py b/agl_service_voiceagent/utils/config.py
index 8d7f346..7295c7f 100644
--- a/agl_service_voiceagent/utils/config.py
+++ b/agl_service_voiceagent/utils/config.py
@@ -14,21 +14,41 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
import configparser
-# Get the absolute path to the directory of the current script
-current_dir = os.path.dirname(os.path.abspath(__file__))
-# Construct the path to the config.ini file located in the base directory
-config_path = os.path.join(current_dir, '..', 'config.ini')
-
config = configparser.ConfigParser()
-config.read(config_path)
+config_path = None
+
+def set_config_path(path):
+ """
+ Sets the path to the config file.
+ """
+ global config_path
+ config_path = path
+ config.read(config_path)
+
+def load_config():
+ """
+ Loads the config file.
+ """
+ if config_path is not None:
+ config.read(config_path)
+ else:
+ raise Exception("Config file path not provided.")
def update_config_value(value, key, group="General"):
+ """
+ Updates a value in the config file.
+ """
+ if config_path is None:
+ raise Exception("Config file path not set.")
+
config.set(group, key, value)
with open(config_path, 'w') as configfile:
config.write(configfile)
def get_config_value(key, group="General"):
+ """
+ Gets a value from the config file.
+ """
return config.get(group, key)