Revision RL

parent 0c68be2b
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
```sh ```sh
python3 -m virtualenv bk_script_env python3 -m virtualenv bk_script_env
source bk_script_env/bin/activate source bk_script_env/bin/activate
pip3 install -r requirements.txt pip3 install -r s3_bk_files-git/requirements.txt
``` ```
## Configuración ## Configuración
...@@ -26,5 +26,6 @@ pip3 install -r requirements.txt ...@@ -26,5 +26,6 @@ pip3 install -r requirements.txt
## Ejecución ## Ejecución
```sh ```sh
cd s3_bk_files-git
python3 -m s3_bk_files python3 -m s3_bk_files
``` ```
...@@ -37,7 +37,6 @@ def run(): ...@@ -37,7 +37,6 @@ def run():
# Obtener archivos del bucket ordenado # Obtener archivos del bucket ordenado
# por defecto el primer elemento es el más antiguo # por defecto el primer elemento es el más antiguo
lista_s3 = s3Help.sorted_list_keys(config.S3_BUCKET) lista_s3 = s3Help.sorted_list_keys(config.S3_BUCKET)
print(lista_s3)
# Obtener la fecha del ultimo archivo procesado # Obtener la fecha del ultimo archivo procesado
last_datetime = rg.get_last_datetime_file_process() last_datetime = rg.get_last_datetime_file_process()
logger.info(' Fecha del último archivo procesado : '+str(last_datetime)) logger.info(' Fecha del último archivo procesado : '+str(last_datetime))
......
# Bucket # Bucket
S3_BUCKET = 'buckethdi/archivos' #'my-bucket-sagemaker' S3_BUCKET = 'buckethdi' #'my-bucket-sagemaker'
# Carpetas # Carpetas
......
...@@ -129,13 +129,16 @@ class AwsS3Helper: ...@@ -129,13 +129,16 @@ class AwsS3Helper:
''' '''
map_list = list(self.list_keys(prefix_name)) map_list = list(self.list_keys(prefix_name))
# Change UTC ZONE TO LOCAL # Change UTC ZONE TO LOCAL
utc_map_list = [] if map_list:
for obj in map_list : utc_map_list = []
obj['info']['LastModified'] = self.utc_to_local(obj['info']['LastModified']) for obj in map_list :
utc_map_list.append(obj) obj['info']['LastModified'] = self.utc_to_local(obj['info']['LastModified'])
map_list = utc_map_list utc_map_list.append(obj)
get_last_modified = lambda obj: int(obj['info']['LastModified'].strftime('%s')) map_list = utc_map_list
return sorted(map_list, key=get_last_modified, reverse=reverse) 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): def utc_to_local(self,utc_dt):
return utc_dt.replace(tzinfo=timezone.utc).astimezone(tz=None) 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