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 argparse
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .models import GreenCertificate
|
from .models import GreenCertificate
|
||||||
@ -37,24 +38,25 @@ def analyse_qrcode(qrcode: str, additional_info: bool = False,
|
|||||||
valid = certificate.check_signature()
|
valid = certificate.check_signature()
|
||||||
else:
|
else:
|
||||||
valid = True
|
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()
|
valid = valid and certificate.check()
|
||||||
|
|
||||||
if valid:
|
if valid:
|
||||||
print("Pass sanitaire valide")
|
logging.info("Pass sanitaire valide")
|
||||||
|
|
||||||
|
|
||||||
print("Nom :", certificate.family_name)
|
logging.debug("Nom : " + certificate.family_name)
|
||||||
print("Prénom :", certificate.given_name)
|
logging.debug("Prénom : " + certificate.given_name)
|
||||||
print("Date de naissance :", certificate.date_of_birth)
|
logging.debug("Date de naissance : " + certificate.date_of_birth)
|
||||||
|
|
||||||
if additional_info:
|
if additional_info:
|
||||||
# TODO Meilleur affichage
|
# TODO Meilleur affichage
|
||||||
print("Informations supplémentaires :",
|
logging.debug("Informations supplémentaires : "
|
||||||
json.dumps(certificate.result.__dict__, indent=2))
|
+ json.dumps(certificate.result.__dict__, indent=2))
|
||||||
else:
|
else:
|
||||||
print("Pass sanitaire invalide")
|
logging.info("Pass sanitaire invalide")
|
||||||
|
|
||||||
return valid
|
return valid
|
||||||
|
|
||||||
@ -69,9 +71,15 @@ def main():
|
|||||||
help="Affiche toutes les informations.")
|
help="Affiche toutes les informations.")
|
||||||
parser.add_argument('--dontcheck', action='store_true',
|
parser.add_argument('--dontcheck', action='store_true',
|
||||||
help="Ne pas vérifier la signature.")
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
logging.basicConfig(level=args.logging)
|
||||||
|
|
||||||
qrcode = read_qrcode(args.file)
|
qrcode = read_qrcode(args.file)
|
||||||
valid = analyse_qrcode(qrcode, args.full, not args.dontcheck)
|
valid = analyse_qrcode(qrcode, args.full, not args.dontcheck)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user