Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
s3_bk_files-git
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
general
s3_bk_files-git
Commits
78b03069
Commit
78b03069
authored
Jun 27, 2021
by
Roberto Loayza Miljanovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revision RL
parent
0c68be2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
+13
-10
README.md
README.md
+2
-1
app.py
s3_bk_files/app.py
+0
-1
config.py
s3_bk_files/config.py
+1
-1
s3_helper.py
s3_bk_files/src/utils_aws_s3/s3_helper.py
+10
-7
No files found.
README.md
View file @
78b03069
...
@@ -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
```
```
s3_bk_files/app.py
View file @
78b03069
...
@@ -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
))
...
...
s3_bk_files/config.py
View file @
78b03069
# Bucket
# Bucket
S3_BUCKET
=
'buckethdi
/archivos
'
#'my-bucket-sagemaker'
S3_BUCKET
=
'buckethdi'
#'my-bucket-sagemaker'
# Carpetas
# Carpetas
...
...
s3_bk_files/src/utils_aws_s3/s3_helper.py
View file @
78b03069
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment