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
4eb916cd
Commit
4eb916cd
authored
Jan 24, 2020
by
JOSSOUD Olivier
Browse files
HTTPDDU. Use new logger functions.
parent
066fc8c4
Pipeline
#57318
passed with stages
in 1 minute and 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
wimcollect/httpddu.py
wimcollect/httpddu.py
+7
-11
No files found.
wimcollect/httpddu.py
View file @
4eb916cd
...
...
@@ -13,7 +13,7 @@ class Collector(utils.LogConfig):
utils
.
LogConfig
.
__init__
(
self
,
"HTTPDDU"
,
config_parser
,
log
)
self
.
base_url
=
self
.
config
[
self
.
object_id
][
"base_url"
]
def
download_picarro
(
self
,
picarro_id
:
str
,
day
:
datetime
.
date
):
def
download_picarro
(
self
,
picarro_id
:
str
,
day
:
datetime
.
date
)
->
bool
:
"""Download Picarro data file from IPEV's HTTP server.
Parameters
...
...
@@ -32,25 +32,21 @@ class Collector(utils.LogConfig):
dest_filepath
=
self
.
__get_dest_filepath__
(
picarro_id
,
day
,
source_fileurl
)
# Download file
self
.
logger
.
write
(
self
.
object_id
,
"["
+
day_str
+
"]
Downloading DDU Picarro file from "
+
source_fileurl
)
self
.
logger
.
info
(
"
Downloading DDU Picarro file from "
+
source_fileurl
,
day_str
)
response
=
urllib
.
request
.
urlretrieve
(
source_fileurl
,
dest_filepath
)
success
=
response
[
0
]
==
dest_filepath
and
os
.
path
.
exists
(
dest_filepath
)
if
not
success
:
msg
=
"["
+
day_str
+
"] FAILED to download file."
self
.
logger
.
write
(
self
.
object_id
,
msg
)
raise
Exception
(
msg
)
self
.
logger
.
error
(
"FAILED to download file in "
+
dest_filepath
,
day_str
)
else
:
self
.
logger
.
write
(
self
.
object_id
,
"["
+
day_str
+
"]
File downloaded in "
+
dest_filepath
)
self
.
logger
.
info
(
"
File downloaded in "
+
dest_filepath
,
day_str
)
# Recompress file, from ZIP to LZMA
self
.
logger
.
write
(
self
.
object_id
,
"["
+
day_str
+
"]
Re-compressing from ZIP to LZMA..."
)
self
.
logger
.
info
(
"
Re-compressing from ZIP to LZMA..."
,
day_str
)
lzma_filepath
=
utils
.
recompress_file
(
dest_filepath
)
if
lzma_filepath
is
None
:
msg
=
"["
+
day_str
+
"] FAILED to create archive file"
self
.
logger
.
write
(
self
.
object_id
,
msg
)
return
False
self
.
logger
.
error
(
"FAILED to re-compress "
+
dest_filepath
,
day_str
)
else
:
self
.
logger
.
write
(
self
.
object_id
,
"["
+
day_str
+
"]
Done. Archive file: "
+
lzma_filepath
)
self
.
logger
.
info
(
"
Done. Archive file: "
+
lzma_filepath
,
day_str
)
return
True
def
__get_dest_filepath__
(
self
,
picarro_id
:
str
,
day
:
datetime
.
date
,
source_filepath
:
str
)
->
str
:
...
...
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