Revision RL

parent 0c68be2b
......@@ -12,7 +12,7 @@
```sh
python3 -m virtualenv bk_script_env
source bk_script_env/bin/activate
pip3 install -r requirements.txt
pip3 install -r s3_bk_files-git/requirements.txt
```
## Configuración
......@@ -26,5 +26,6 @@ pip3 install -r requirements.txt
## Ejecución
```sh
cd s3_bk_files-git
python3 -m s3_bk_files
```
......@@ -37,7 +37,6 @@ def run():
# 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))
......
# Bucket
S3_BUCKET = 'buckethdi/archivos' #'my-bucket-sagemaker'
S3_BUCKET = 'buckethdi' #'my-bucket-sagemaker'
# Carpetas
......
......@@ -129,13 +129,16 @@ class AwsS3Helper:
'''
map_list = list(self.list_keys(prefix_name))
# Change UTC ZONE TO LOCAL
utc_map_list = []
for obj in map_list :
obj['info']['LastModified'] = self.utc_to_local(obj['info']['LastModified'])
utc_map_list.append(obj)
map_list = utc_map_list
get_last_modified = lambda obj: int(obj['info']['LastModified'].strftime('%s'))
return sorted(map_list, key=get_last_modified, reverse=reverse)
if map_list:
utc_map_list = []
for obj in map_list :
obj['info']['LastModified'] = self.utc_to_local(obj['info']['LastModified'])
utc_map_list.append(obj)
map_list = utc_map_list
get_last_modified = lambda obj: int(obj['info']['LastModified'].strftime('%s'))
return sorted(map_list, key=get_last_modified, reverse=reverse)
else:
raise Exception("No hay archivos a procesar en el bucket. Por favor, revise el archivo de configuración o confirme que no hay archivos en el Bucket configurado")
def utc_to_local(self,utc_dt):
return utc_dt.replace(tzinfo=timezone.utc).astimezone(tz=None)
......
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