Skip to content

Commit

Permalink
Create the cache file if it does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkagwi committed Jan 28, 2025
1 parent 2c70d0c commit 0162dc6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/odk_publish/etl/odk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def __init__(self, base_url: str, project_id: int | None = None):
config_path = Path("/tmp/.pyodk_config.toml")
if not config_path.exists():
config_path.write_text(CONFIG_TOML)
# Create stub cache file if it doesn't exist, so that pyodk doesn't complain
cache_path = Path("/tmp/.pyodk_cache.toml")
if not cache_path.exists():
cache_path.write_text('token = ""')
# Create a session with the given authentication details and supply the
# session to the super class, so it doesn't try and create one itself
server_config = self.get_config(base_url=base_url)
Expand All @@ -49,7 +53,7 @@ def __init__(self, base_url: str, project_id: int | None = None):
api_version="v1",
username=server_config.username,
password=server_config.password.get_secret_value(),
cache_path="/tmp/.pyodk_cache.toml",
cache_path=str(cache_path),
)
super().__init__(config_path=str(config_path), session=session, project_id=project_id)
# Update the stub config with the environment-provided authentication
Expand Down

0 comments on commit 0162dc6

Please sign in to comment.