Skip to content

Commit

Permalink
create .rai if necessary (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
sswatson authored Mar 2, 2024
1 parent 1a41831 commit 724a67e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion railib/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import json
import logging
from os import path
from os import path, makedirs
from urllib.error import URLError
from urllib.parse import urlencode, urlsplit, quote
from urllib.request import Request, urlopen
Expand Down Expand Up @@ -151,6 +151,8 @@ def _read_token_cache(creds: ClientCredentials) -> AccessToken:
# write access token to cache
def _write_token_cache(creds: ClientCredentials):
try:
cache_dir = path.dirname(_cache_file())
makedirs(cache_dir, exist_ok=True)
cache = _read_cache()
cache[creds.client_id] = creds.access_token
with open(_cache_file(), 'w') as f:
Expand Down

0 comments on commit 724a67e

Please sign in to comment.