mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
Hardware abstraction class (#2080)
* hardware abstraction class * De Morgan * Rename pc hardware class * Fix sound card in controlsd * Pc get sim info * fix hardware in test * two more * No more random imei on android * no randomness on android * Need to return something that looks like imei for registration to work * Return proper network strength * Unused import * Bug fixes + gpsd is only android old-commit-hash: c7152d54192605c833912b69cf85514ac2e1b1fc
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
import json
|
||||
import os
|
||||
from common.android import ANDROID
|
||||
from common.hardware import PC
|
||||
from common.file_helpers import mkdirs_exists_ok
|
||||
|
||||
|
||||
class MissingAuthConfigError(Exception):
|
||||
pass
|
||||
|
||||
if ANDROID:
|
||||
CONFIG_DIR = "/tmp/.comma"
|
||||
else:
|
||||
|
||||
if PC:
|
||||
CONFIG_DIR = os.path.expanduser('~/.comma')
|
||||
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:
|
||||
@@ -20,9 +24,11 @@ def get_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'))
|
||||
|
||||
Reference in New Issue
Block a user