mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 08:53:54 +08:00
* kind of works * move that * hack to get camerad to reliably terminate * not sure why SIGTERM wasn't working before * compare bytes * clean up some hacks * gitignore * fix that * WIP * no reboot * comparison works * pretty print * fix build * run in jenkins * python path * space * raise timeout * new eon * skip the copy * spinner * spin less * update model ref commit * reenable that * clean up * fix jenkinsfile * parallel * wrap it in a stage * fix linter * better progress * lower timeout Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
29 lines
712 B
Python
29 lines
712 B
Python
import json
|
|
import os
|
|
from common.android import ANDROID
|
|
from common.file_helpers import mkdirs_exists_ok
|
|
|
|
class MissingAuthConfigError(Exception):
|
|
pass
|
|
|
|
if ANDROID:
|
|
CONFIG_DIR = "/tmp/.comma"
|
|
else:
|
|
CONFIG_DIR = os.path.expanduser('~/.comma')
|
|
mkdirs_exists_ok(CONFIG_DIR)
|
|
|
|
def get_token():
|
|
try:
|
|
with open(os.path.join(CONFIG_DIR, 'auth.json')) as f:
|
|
auth = json.load(f)
|
|
return auth['access_token']
|
|
except Exception:
|
|
raise MissingAuthConfigError('Authenticate with tools/lib/auth.py')
|
|
|
|
def set_token(token):
|
|
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'))
|