Files
controller-wisetopdataserver/python/biopro/server/_identify.py
T
2021-12-20 14:52:55 +08:00

40 lines
922 B
Python

import uuid
import requests
API_SERVER_HOST = 'http://192.168.0.192'
API_SERVER_PORT = 3000
# API_SERVER_AUTH_TOKEN = requests.get(API_SERVER_HOST + ':' + str(API_SERVER_PORT) + '/public/auth/get_cookie').text
_jwt = None
def controller_device_id() -> str:
### device ID
return 'b8:27:eb:52:ea:97'
ret = None
try:
with open('/etc/BPS/device_id') as f:
for line in f:
if line.startswith('#'):
continue
ret = line.strip()
break
except FileNotFoundError:
pass
if ret is None or len(ret) == 0:
return str(uuid.uuid1())
else:
return ret
def get_api_jwt() -> str:
global _jwt
return _jwt
def set_api_jwt(jwt = None) -> str:
### jwt
global _jwt
if jwt is not None:
_jwt = jwt
print('set_api_jwt', _jwt)
print('get_api_jwt', get_api_jwt())