Skip to content

Commit 724a67e

Browse files
authored
create .rai if necessary (#147)
1 parent 1a41831 commit 724a67e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

railib/rest.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import json
1818
import logging
19-
from os import path
19+
from os import path, makedirs
2020
from urllib.error import URLError
2121
from urllib.parse import urlencode, urlsplit, quote
2222
from urllib.request import Request, urlopen
@@ -151,6 +151,8 @@ def _read_token_cache(creds: ClientCredentials) -> AccessToken:
151151
# write access token to cache
152152
def _write_token_cache(creds: ClientCredentials):
153153
try:
154+
cache_dir = path.dirname(_cache_file())
155+
makedirs(cache_dir, exist_ok=True)
154156
cache = _read_cache()
155157
cache[creds.client_id] = creds.access_token
156158
with open(_cache_file(), 'w') as f:

0 commit comments

Comments
 (0)