mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 00:43:54 +08:00
importing auth_config.py should not have side effects (#29893)
import should not create directory
old-commit-hash: 140a4ba558
This commit is contained in:
@@ -13,9 +13,6 @@ if PC:
|
||||
else:
|
||||
CONFIG_DIR = "/tmp/.comma"
|
||||
|
||||
mkdirs_exists_ok(CONFIG_DIR)
|
||||
|
||||
|
||||
def get_token():
|
||||
try:
|
||||
with open(os.path.join(CONFIG_DIR, 'auth.json')) as f:
|
||||
@@ -26,9 +23,13 @@ def get_token():
|
||||
|
||||
|
||||
def set_token(token):
|
||||
mkdirs_exists_ok(CONFIG_DIR)
|
||||
with open(os.path.join(CONFIG_DIR, 'auth.json'), 'w') as f:
|
||||
json.dump({'access_token': token}, f)
|
||||
|
||||
|
||||
def clear_token():
|
||||
os.unlink(os.path.join(CONFIG_DIR, 'auth.json'))
|
||||
try:
|
||||
os.unlink(os.path.join(CONFIG_DIR, 'auth.json'))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user