Fix nfc-list lines
This commit is contained in:
parent
e6ca31fbec
commit
215187874c
17
server.py
17
server.py
@ -24,7 +24,7 @@ def runCommand(command):
|
|||||||
|
|
||||||
### Partie Flask (Serveur Web)
|
### Partie Flask (Serveur Web)
|
||||||
app = Flask('__name__', static_folder="res")
|
app = Flask('__name__', static_folder="res")
|
||||||
app.config['DEBUG'] = False
|
app.config['DEBUG'] = True
|
||||||
|
|
||||||
|
|
||||||
# Page principal
|
# Page principal
|
||||||
@ -52,9 +52,9 @@ def detectBadge():
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
stdout = stdout.decode("utf-8")
|
stdout = stdout.decode("utf-8")
|
||||||
lines = stdout.split('\n')
|
lines = stdout.split('\n')
|
||||||
if "Interface opened" in lines[1]:
|
if "Interface opened" in lines[0]:
|
||||||
if len(lines) > 6:
|
if len(lines) > 6:
|
||||||
badge_type = lines[4].replace(' ', ' ')
|
badge_type = lines[3].replace(' ', ' ')
|
||||||
if '00 04' in badge_type:
|
if '00 04' in badge_type:
|
||||||
result = {'status': 'OK'}
|
result = {'status': 'OK'}
|
||||||
break
|
break
|
||||||
@ -76,11 +76,12 @@ def readBadge():
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
stdout = stdout.decode("utf-8")
|
stdout = stdout.decode("utf-8")
|
||||||
lines = stdout.split('\n')
|
lines = stdout.split('\n')
|
||||||
if "Interface opened" in lines[1]:
|
print(lines)
|
||||||
|
if "Interface opened" in lines[0]:
|
||||||
if len(lines) > 6:
|
if len(lines) > 6:
|
||||||
badge_type = lines[4].replace(' ', ' ')
|
badge_type = lines[3].replace(' ', ' ')
|
||||||
if '00 04' in badge_type:
|
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
|
# 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:
|
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}
|
result = {'status': 'OK', 'UID': badge_UID}
|
||||||
@ -134,9 +135,9 @@ def copyBadge(uid):
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
stdout = stdout.decode("utf-8")
|
stdout = stdout.decode("utf-8")
|
||||||
lines = stdout.split('\n')
|
lines = stdout.split('\n')
|
||||||
if "Interface opened" in lines[1]:
|
if "Interface opened" in lines[0]:
|
||||||
if len(lines) > 6:
|
if len(lines) > 6:
|
||||||
badge_type = lines[4].replace(' ', ' ')
|
badge_type = lines[3].replace(' ', ' ')
|
||||||
if '00 04' in badge_type:
|
if '00 04' in badge_type:
|
||||||
stdout, stderr, status_code = runCommand('mfoc -P 500 -O %s/new.dmp' % DUMPS_DIR)
|
stdout, stderr, status_code = runCommand('mfoc -P 500 -O %s/new.dmp' % DUMPS_DIR)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user