Se cambia la lógica para evitar que el token caduque

This commit is contained in:
El Mau 2022-02-05 22:22:24 -06:00
parent 176415c1fe
commit 72fa18f511
4 changed files with 25 additions and 14 deletions

View File

@ -1,6 +1,11 @@
# Lista de cambios
## v 0.5.0 [06-Feb-22]
---
* Se cambia la lógica para evitar el error de token caducado.
## v 0.4.0 [02-Sep-21]
---
* Se agrega soporte para descargar metadatos

View File

@ -8,17 +8,13 @@ Descarga masiva del SAT
En orden de preferencia
Mauricio Baeza
* G1: `A5DdXxCKPw3QKWVdDVs7CzkNugNUW1sHu5zDJFWxCU2h`
```
Euros
IBAN: BE60 9671 0556 5870
SWIFT / BIC: TRWIBEB1XXX
```
* BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
* ETH: `0x61a4f614a30ff686445751ed8328b82b77ecfc69`
* XRP: `rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK` Tag: `6643162`
* LTC: `MBcgQ3LQJA4W2wsXknTdm2fxRSysLaBJHS`
* BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
Mira la [documentación](https://git.cuates.net/elmau/cfdi-descarga/wiki/Inicio)

View File

@ -1,4 +1,4 @@
httpx
peewee
cryptography
cryptography==3.4.8
lxml

View File

@ -76,7 +76,13 @@ def fiel_validar(args):
if not result:
return
password = getpass.getpass('Introduce la contraseña del archivo KEY: ')
try:
password = getpass.getpass('Introduce la contraseña del archivo KEY: ')
except KeyboardInterrupt:
msg = 'Proceso cancelado'
log.info(msg)
return
if not password:
msg = 'La contraseña es requerida para validar la FIEL'
log.error(msg)
@ -372,9 +378,11 @@ def _validate_args(args):
return True, data
def _download(sat, data, key):
def _download(data, key):
OK = '5000'
sat = SATWebService(data['cert'])
result = _request_download(sat, data, key)
if result['CodEstatus'] != OK:
log.error(result)
@ -389,7 +397,9 @@ def _download(sat, data, key):
sleep(1)
while True:
sat = SATWebService(data['cert'])
result = sat.verify(data)
if result['EstadoSolicitud'] in ('1', '2'):
msg = 'Esperando un minuto más para volver a verificar...'
log.info(msg)
@ -432,12 +442,12 @@ def descargar(args):
return
if data['type'] == 'e':
_download(sat, data, 'RfcEmisor')
_download(data, 'RfcEmisor')
elif data['type'] == 'r':
_download(sat, data, 'RfcReceptor')
_download(data, 'RfcReceptor')
else:
_download(sat, data, 'RfcEmisor')
_download(sat, data, 'RfcReceptor')
_download(data, 'RfcEmisor')
_download(data, 'RfcReceptor')
return