Skip to content

Commit

Permalink
Ensure config directory exists before writing to it in hana_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Feb 7, 2024
1 parent 8f1b8c3 commit e82afcf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions neon_utils/hana_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import requests
import json

from os.path import join, isfile
from os import makedirs
from os.path import join, isfile, isdir, dirname
from time import time
from typing import Optional
from ovos_utils.log import LOG
from ovos_utils.xdg_utils import xdg_cache_home

Expand Down Expand Up @@ -84,6 +84,8 @@ def _get_token(backend_address: str, username: str = "guest",
raise ServerException(f"Error logging into {backend_address}. "
f"{resp.status_code}: {resp.text}")
_client_config = resp.json()
if not isdir(dirname(_client_config_path)):
makedirs(dirname(_client_config_path))
with open(_client_config_path, "w+") as f:
json.dump(_client_config, f, indent=2)

Expand Down

0 comments on commit e82afcf

Please sign in to comment.