From 215187874c6f63defb41de586fa16695f856f048 Mon Sep 17 00:00:00 2001 From: jarjar Date: Wed, 31 May 2023 20:37:13 +0200 Subject: [PATCH] Fix nfc-list lines --- server.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/server.py b/server.py index d88797b..2c71501 100644 --- a/server.py +++ b/server.py @@ -24,7 +24,7 @@ def runCommand(command): ### Partie Flask (Serveur Web) app = Flask('__name__', static_folder="res") -app.config['DEBUG'] = False +app.config['DEBUG'] = True # Page principal @@ -52,9 +52,9 @@ def detectBadge(): time.sleep(2) stdout = stdout.decode("utf-8") lines = stdout.split('\n') - if "Interface opened" in lines[1]: + if "Interface opened" in lines[0]: if len(lines) > 6: - badge_type = lines[4].replace(' ', ' ') + badge_type = lines[3].replace(' ', ' ') if '00 04' in badge_type: result = {'status': 'OK'} break @@ -76,11 +76,12 @@ def readBadge(): time.sleep(2) stdout = stdout.decode("utf-8") lines = stdout.split('\n') - if "Interface opened" in lines[1]: + print(lines) + if "Interface opened" in lines[0]: if len(lines) > 6: - badge_type = lines[4].replace(' ', ' ') + badge_type = lines[3].replace(' ', ' ') if '00 04' in badge_type: - badge_UID = lines[5].replace('UID (NFCID1): ', '').replace(' ', '') + badge_UID = lines[4].replace('UID (NFCID1): ', '').replace(' ', '') # Si un dump existe déjà pour cet UID et qu'il est complet if ((os.path.isfile('%s/%s.dmp' % (DUMPS_DIR, badge_UID))) and (os.path.getsize('%s/%s.dmp' % (DUMPS_DIR, badge_UID)))) == 1024: result = {'status': 'OK', 'UID': badge_UID} @@ -134,9 +135,9 @@ def copyBadge(uid): time.sleep(2) stdout = stdout.decode("utf-8") lines = stdout.split('\n') - if "Interface opened" in lines[1]: + if "Interface opened" in lines[0]: if len(lines) > 6: - badge_type = lines[4].replace(' ', ' ') + badge_type = lines[3].replace(' ', ' ') if '00 04' in badge_type: stdout, stderr, status_code = runCommand('mfoc -P 500 -O %s/new.dmp' % DUMPS_DIR) time.sleep(2)