Ajout d'options de verbosité
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
07410eded3
commit
d92c55fd42
|
@ -2,6 +2,7 @@
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from .models import GreenCertificate
|
||||
|
@ -37,24 +38,25 @@ def analyse_qrcode(qrcode: str, additional_info: bool = False,
|
|||
valid = certificate.check_signature()
|
||||
else:
|
||||
valid = True
|
||||
print("Attention : la signature du QR code n'a pas été vérifiée.")
|
||||
logging.warning("Attention : la signature du"
|
||||
"QR code n'a pas été vérifiée.")
|
||||
|
||||
valid = valid and certificate.check()
|
||||
|
||||
if valid:
|
||||
print("Pass sanitaire valide")
|
||||
logging.info("Pass sanitaire valide")
|
||||
|
||||
|
||||
print("Nom :", certificate.family_name)
|
||||
print("Prénom :", certificate.given_name)
|
||||
print("Date de naissance :", certificate.date_of_birth)
|
||||
logging.debug("Nom : " + certificate.family_name)
|
||||
logging.debug("Prénom : " + certificate.given_name)
|
||||
logging.debug("Date de naissance : " + certificate.date_of_birth)
|
||||
|
||||
if additional_info:
|
||||
# TODO Meilleur affichage
|
||||
print("Informations supplémentaires :",
|
||||
json.dumps(certificate.result.__dict__, indent=2))
|
||||
logging.debug("Informations supplémentaires : "
|
||||
+ json.dumps(certificate.result.__dict__, indent=2))
|
||||
else:
|
||||
print("Pass sanitaire invalide")
|
||||
logging.info("Pass sanitaire invalide")
|
||||
|
||||
return valid
|
||||
|
||||
|
@ -69,9 +71,15 @@ def main():
|
|||
help="Affiche toutes les informations.")
|
||||
parser.add_argument('--dontcheck', action='store_true',
|
||||
help="Ne pas vérifier la signature.")
|
||||
parser.add_argument('--logging', '-l', default=logging.DEBUG,
|
||||
choices=['DEBUG', 'INFO', 'WARNING',
|
||||
'ERROR', 'CRITICAL'],
|
||||
help="Niveau de verbosité.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=args.logging)
|
||||
|
||||
qrcode = read_qrcode(args.file)
|
||||
valid = analyse_qrcode(qrcode, args.full, not args.dontcheck)
|
||||
|
||||
|
|
Loading…
Reference in New Issue