Commit 16cc8915 authored by criq's avatar criq

rename files

parent 06058ae4
......@@ -26,5 +26,5 @@ pip3 install -r requirements.txt
## Ejecución
```sh
python3 -m s3_local_manager
python3 -m s3_bk_files
```
......@@ -33,46 +33,46 @@ def run():
tic = time.time()
try:
s3Help = AwsS3Helper(aws_access_key_id,aws_secret_access_key,aws_region)
# Obtener archivos del bucket ordenado
# por defecto el primer elemento es el más antiguo
lista_s3 = s3Help.sorted_list_keys(config.S3_BUCKET)
print(lista_s3)
# Obtener la fecha del ultimo archivo procesado
last_datetime = rg.get_last_datetime_file_process()
logger.info(' Fecha del último archivo procesado : '+str(last_datetime))
s3Help = AwsS3Helper(aws_access_key_id,aws_secret_access_key,aws_region)
# Obtener archivos del bucket ordenado
# por defecto el primer elemento es el más antiguo
lista_s3 = s3Help.sorted_list_keys(config.S3_BUCKET)
print(lista_s3)
# Obtener la fecha del ultimo archivo procesado
last_datetime = rg.get_last_datetime_file_process()
logger.info(' Fecha del último archivo procesado : '+str(last_datetime))
## Filtrar lista por la fecha anterior
filter_list_s3 = s3Help.filter_by_datetime(lista_s3,last_datetime)
if len(filter_list_s3) == 0 and last_datetime != None:
logger.warning(' No hay nuevos archivos a procesar ... ')
elif last_datetime == None:
filter_list_s3 = lista_s3
## Filtrar lista por la fecha anterior
filter_list_s3 = s3Help.filter_by_datetime(lista_s3,last_datetime)
if len(filter_list_s3) == 0 and last_datetime != None:
logger.warning(' No hay nuevos archivos a procesar ... ')
elif last_datetime == None:
filter_list_s3 = lista_s3
print('**** ')
# Clase para gestionar carpetas locales
locaTemplHelper = LocalFilesHelper(config.local_folder_temp)
locaDefinitivelHelper = LocalFilesHelper(config.local_folder_definitive)
print('**** ')
# Clase para gestionar carpetas locales
locaTemplHelper = LocalFilesHelper(config.local_folder_temp)
locaDefinitivelHelper = LocalFilesHelper(config.local_folder_definitive)
# iterar archivos
# guardar el último
last_file = None
for s3_file in filter_list_s3:
local_dest_file = locaTemplHelper.create_pathfile_for_dict(s3_file)
if local_dest_file:
# Retorna True si ya esta registrado
is_registred = rg.registry_file_dict(s3_file)
if not is_registred:
s3Help.download_file_from_dict(s3_file,local_dest_file)
print(local_dest_file)
# guardar en el otro directorio tambien
locaDefinitivelHelper.move_file(local_dest_file)
last_file = s3_file
print('_'*60)
# iterar archivos
# guardar el último
last_file = None
for s3_file in filter_list_s3:
local_dest_file = locaTemplHelper.create_pathfile_for_dict(s3_file)
if local_dest_file:
# Retorna True si ya esta registrado
is_registred = rg.registry_file_dict(s3_file)
if not is_registred:
s3Help.download_file_from_dict(s3_file,local_dest_file)
print(local_dest_file)
# guardar en el otro directorio tambien
locaDefinitivelHelper.move_file(local_dest_file)
last_file = s3_file
print('_'*60)
toc = time.time()
rg.save_process_time(start_time,tic,toc,last_file)
toc = time.time()
rg.save_process_time(start_time,tic,toc,last_file)
except Exception as e:
logger.error('Existe un problema en el proceso: %s', e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment