Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
JOSSOUD Olivier
WIM Collect
Commits
a93ace6a
Commit
a93ace6a
authored
Jan 29, 2020
by
JOSSOUD Olivier
Browse files
FTPSIRTA. MeteoFrance data.
parent
951a1524
Pipeline
#57848
passed with stages
in 3 minutes and 12 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
wimcollect/ftpsirta.py
wimcollect/ftpsirta.py
+41
-0
wimcollect/tests/test_ftpsirta.py
wimcollect/tests/test_ftpsirta.py
+10
-0
No files found.
wimcollect/ftpsirta.py
0 → 100644
View file @
a93ace6a
import
configobj
import
datetime
import
wimcollect.common.logger
as
logger
import
wimcollect.common.ftp
as
ftp
import
wimcollect.common.utils
as
utils
class
SirtaMfCollector
(
utils
.
LogConfig
):
"""Collector for Sirta's Meteo-France meteo data file"""
def
__init__
(
self
,
config_parser
:
configobj
.
ConfigObj
=
None
,
log
:
logger
=
None
):
self
.
object_id
=
"FTPSIRTA"
utils
.
LogConfig
.
__init__
(
self
,
self
.
object_id
,
config_parser
,
log
)
self
.
distant_base_dir
=
self
.
config
[
self
.
object_id
][
"distant_base_dir"
]
def
download
(
self
,
day
:
datetime
.
date
):
"""Download Sirta's Meteo-France meteo data file.
Parameters
----------
day: datetime.date
Date of the data which should be downloaded.
"""
date_str
=
day
.
strftime
(
"%Y%m%d"
)
self
.
logger
.
date_str
=
date_str
# Build source and destination file paths
source_filepath
=
self
.
distant_base_dir
+
"/"
+
day
.
strftime
(
"%Y/%m/%d/"
)
+
\
"meteoairsol_1a_Lz1NairF1minPtuvPrain_v01_"
+
date_str
+
"_000000_1440.asc"
dest_filepath
=
utils
.
get_standard_filepath
(
self
.
local_base_dir
,
"SRT"
,
"meteo"
,
"sirtamf"
,
date_str
,
"tsv"
)
# Download
success
=
ftp
.
download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
ftp_config
=
self
.
config
[
self
.
object_id
])
# Compress
if
success
:
utils
.
compress_file
(
dest_filepath
,
self
.
logger
)
return
True
wimcollect/tests/test_ftpsirta.py
0 → 100644
View file @
a93ace6a
import
datetime
from
unittest
import
TestCase
import
wimcollect.ftpsirta
as
ftpsirta
class
TestSirtaMfCollector
(
TestCase
):
def
test_download
(
self
):
collector
=
ftpsirta
.
SirtaMfCollector
()
self
.
assertTrue
(
collector
.
download
(
datetime
.
date
(
2020
,
1
,
1
)))
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