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
7d500ea0
Commit
7d500ea0
authored
Jan 24, 2020
by
JOSSOUD Olivier
Browse files
FTP. Functions have no more reason to be private.
parent
e45fa970
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
15 deletions
+15
-15
wimcollect/common/ftp.py
wimcollect/common/ftp.py
+5
-5
wimcollect/ftpaeris.py
wimcollect/ftpaeris.py
+2
-2
wimcollect/ftpcea.py
wimcollect/ftpcea.py
+6
-6
wimcollect/ftpopar.py
wimcollect/ftpopar.py
+2
-2
No files found.
wimcollect/common/ftp.py
View file @
7d500ea0
...
@@ -40,7 +40,7 @@ def ftp_connect(ftp_config: dict, log: logger.Logger, object_id: str) -> ftplib.
...
@@ -40,7 +40,7 @@ def ftp_connect(ftp_config: dict, log: logger.Logger, object_id: str) -> ftplib.
return
session
return
session
def
_
ftp_list_files
_
(
ftp_session
:
ftplib
.
FTP
,
distant_directory_path
:
str
,
log
:
logger
.
Logger
,
object_id
:
str
)
->
list
:
def
ftp_list_files
(
ftp_session
:
ftplib
.
FTP
,
distant_directory_path
:
str
,
log
:
logger
.
Logger
,
object_id
:
str
)
->
list
:
"""List the files in the distant FTP directory.
"""List the files in the distant FTP directory.
Parameters
Parameters
...
@@ -72,7 +72,7 @@ def _ftp_list_files_(ftp_session: ftplib.FTP, distant_directory_path: str, log:
...
@@ -72,7 +72,7 @@ def _ftp_list_files_(ftp_session: ftplib.FTP, distant_directory_path: str, log:
return
filepaths
return
filepaths
def
_
ftp_download_file
(
source_filepath
:
str
,
dest_filepath
:
str
,
def
ftp_download_file
(
source_filepath
:
str
,
dest_filepath
:
str
,
log
:
logger
.
Logger
,
object_id
:
str
,
log
:
logger
.
Logger
,
object_id
:
str
,
ftp_config
:
dict
=
None
,
ftp_session
:
ftplib
.
FTP
=
None
,
ftp_config
:
dict
=
None
,
ftp_session
:
ftplib
.
FTP
=
None
,
delete_if_success
:
bool
=
False
)
->
bool
:
delete_if_success
:
bool
=
False
)
->
bool
:
...
...
wimcollect/ftpaeris.py
View file @
7d500ea0
...
@@ -28,7 +28,7 @@ class Collector(utils.LogConfig):
...
@@ -28,7 +28,7 @@ class Collector(utils.LogConfig):
dest_filepath
=
self
.
__get_dest_filepath__
(
yyyymm
)
dest_filepath
=
self
.
__get_dest_filepath__
(
yyyymm
)
# Download
# Download
success
=
ftp
.
_
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
success
=
ftp
.
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
ftp_config
=
self
.
config
[
self
.
object_id
])
ftp_config
=
self
.
config
[
self
.
object_id
])
# Compress
# Compress
...
...
wimcollect/ftpcea.py
View file @
7d500ea0
...
@@ -40,14 +40,14 @@ class Collector(utils.LogConfig):
...
@@ -40,14 +40,14 @@ class Collector(utils.LogConfig):
source_filepath
=
source_dir
+
source_filename
source_filepath
=
source_dir
+
source_filename
# Check that to-be-downloaded file exists
# Check that to-be-downloaded file exists
source_filepaths
=
ftp
.
_
ftp_list_files
_
(
ftp_session
,
source_dir
,
self
.
logger
,
self
.
object_id
)
source_filepaths
=
ftp
.
ftp_list_files
(
ftp_session
,
source_dir
,
self
.
logger
,
self
.
object_id
)
if
source_filepath
not
in
source_filepaths
:
if
source_filepath
not
in
source_filepaths
:
self
.
logger
.
write
(
self
.
object_id
,
"File not found: "
+
source_filepath
)
self
.
logger
.
write
(
self
.
object_id
,
"File not found: "
+
source_filepath
)
raise
FileNotFoundError
(
source_filepath
)
raise
FileNotFoundError
(
source_filepath
)
# Download file
# Download file
dest_filepath
=
self
.
__get_picarro_dest_filepath__
(
source_filepath
)
dest_filepath
=
self
.
__get_picarro_dest_filepath__
(
source_filepath
)
success
=
ftp
.
_
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
success
=
ftp
.
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
ftp_session
=
ftp_session
)
ftp_session
=
ftp_session
)
ftp_session
.
quit
()
ftp_session
.
quit
()
...
@@ -96,10 +96,10 @@ class Collector(utils.LogConfig):
...
@@ -96,10 +96,10 @@ class Collector(utils.LogConfig):
ftp_session
=
ftp
.
ftp_connect
(
self
.
config
[
self
.
object_id
],
self
.
logger
,
self
.
object_id
)
ftp_session
=
ftp
.
ftp_connect
(
self
.
config
[
self
.
object_id
],
self
.
logger
,
self
.
object_id
)
hobo_distant_path
=
self
.
distant_base_dir
+
"/"
+
site_id
+
"/hobo/"
hobo_distant_path
=
self
.
distant_base_dir
+
"/"
+
site_id
+
"/hobo/"
source_filepaths
=
ftp
.
_
ftp_list_files
_
(
ftp_session
,
hobo_distant_path
,
self
.
logger
,
self
.
object_id
)
source_filepaths
=
ftp
.
ftp_list_files
(
ftp_session
,
hobo_distant_path
,
self
.
logger
,
self
.
object_id
)
for
source_filepath
in
source_filepaths
:
for
source_filepath
in
source_filepaths
:
dest_filepath
=
self
.
__get_hobo_dest_filepath__
(
source_filepath
)
dest_filepath
=
self
.
__get_hobo_dest_filepath__
(
source_filepath
)
ftp
.
_
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
ftp
.
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
ftp_session
=
ftp_session
)
ftp_session
=
ftp_session
)
ftp_session
.
quit
()
ftp_session
.
quit
()
...
...
wimcollect/ftpopar.py
View file @
7d500ea0
...
@@ -32,7 +32,7 @@ class Collector(utils.LogConfig):
...
@@ -32,7 +32,7 @@ class Collector(utils.LogConfig):
dest_filepath
=
self
.
__get_dest_filepath__
(
day
)
dest_filepath
=
self
.
__get_dest_filepath__
(
day
)
# Download
# Download
success
=
ftp
.
_
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
success
=
ftp
.
ftp_download_file
(
source_filepath
,
dest_filepath
,
self
.
logger
,
self
.
object_id
,
ftp_config
=
self
.
config
[
self
.
object_id
])
ftp_config
=
self
.
config
[
self
.
object_id
])
# Compress
# Compress
...
...
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