importing auth_config.py should not have side effects (#29893)

import should not create directory
pull/29894/head
Greg Hogan 2 years ago committed by GitHub
parent 9b959dc86e
commit 140a4ba558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      tools/lib/auth_config.py

@ -13,9 +13,6 @@ if PC:
else: else:
CONFIG_DIR = "/tmp/.comma" CONFIG_DIR = "/tmp/.comma"
mkdirs_exists_ok(CONFIG_DIR)
def get_token(): def get_token():
try: try:
with open(os.path.join(CONFIG_DIR, 'auth.json')) as f: with open(os.path.join(CONFIG_DIR, 'auth.json')) as f:
@ -26,9 +23,13 @@ def get_token():
def set_token(token): def set_token(token):
mkdirs_exists_ok(CONFIG_DIR)
with open(os.path.join(CONFIG_DIR, 'auth.json'), 'w') as f: with open(os.path.join(CONFIG_DIR, 'auth.json'), 'w') as f:
json.dump({'access_token': token}, f) json.dump({'access_token': token}, f)
def clear_token(): 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

Loading…
Cancel
Save