* Upgrade service to integrate with new FPrint OS.

This commit is contained in:
2022-01-30 17:46:52 +01:00
parent 8bbfb59c6b
commit 3c5fbbf46b
2 changed files with 33 additions and 13 deletions
+22 -6
View File
@@ -1,3 +1,4 @@
import datetime
import json
import socketio
import uuid
@@ -19,11 +20,18 @@ config = {
},
'mode': 'capture'
}
config_default = config;
os.chdir(os.path.dirname(__file__));
configFileExists = os.path.exists('.config.json');
if configFileExists:
with open('.config.json') as reader:
config = json.loads(reader.read());
try:
config = json.loads(reader.read());
except:
config = config_default
sio = socketio.Server(async_mode="threading")
app = Flask(__name__)
@@ -260,18 +268,26 @@ def connect(sid, data):
config['started'] = is_identify_active
domain_code = config['domain']['code'];
response = requests.get("https://apis.a2loft.net/identity/{}/units".format(domain_code))
responseJson = json.loads(response.text)
if responseJson['ok']:
config['departments'] = responseJson['data'];
config['departments'] = [];
if response.ok:
responseJson = json.loads(response.text)
if responseJson['ok']:
config['departments'] = responseJson['data'];
domain_fprint_file = '{}/fprint-sync/.{}-fprint-data.json'.format(os.getenv("HOME"), domain_code);
config['records'] = {
'length': 0,
'timestamp': 0
};
if os.path.exists(domain_fprint_file):
with open(domain_fprint_file) as f:
records = json.loads(f.read());
raw_prints = records['profiles'];
prints_dict = {};
for profile in raw_prints:
for fp in profile['fingerprints']:
prints_dict[fp] = profile
for index, fp in enumerate(profile['fingerprints']):
reference = profile['reference'];
finger = fp['finger']
prints_dict['{}-{}-{}'.format(reference, finger, index+1)] = profile
config['records'] = {
'length': len(records['profiles']),
'timestamp': records['timestamp']