Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
europa-erp-python
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
66f5e99e
authored
Jun 23, 2025
by
刘豪
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
hk压缩包自身有问题
parent
22b7fa3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
rs_data.py
utils/ftp.py
rs_data.py
View file @
66f5e99e
...
...
@@ -198,10 +198,11 @@ def get_supplier_id(supplier_name: str, conf: dict) -> int:
def
down_and_handle
(
ftp_client
):
"""download the zip file"""
logger
.
info
(
"下载压缩包"
)
ftp_client
.
download
(
remote_file_name_1
,
conf_environment
[
"tmp_file_path"
]
+
local_file_name_1
)
extract_dir
=
conf_environment
[
"tmp_file_path"
]
+
"extract/"
# ftp_client.download(remote_file_name_1, conf_environment["tmp_file_path"] + local_file_name_1)
ftp_client
.
download
(
remote_file_name_3
,
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
)
extract_dir
=
conf_environment
[
"tmp_file_path"
]
+
"extract/"
if
not
os
.
path
.
exists
(
extract_dir
):
os
.
makedirs
(
extract_dir
)
...
...
@@ -209,7 +210,7 @@ def down_and_handle(ftp_client):
try
:
logger
.
info
(
"解压压缩包"
)
file_handle
.
unzip
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_1
,
extract_dir
)
#
file_handle.unzip(conf_environment["tmp_file_path"] + local_file_name_1, extract_dir)
file_handle
.
unzip
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
,
extract_dir
)
...
...
@@ -219,11 +220,17 @@ def down_and_handle(ftp_client):
if
rs_cn_supplier_id
==
-
1
or
rs_hk_supplier_id
==
-
1
:
logger
.
info
(
"不支持的supplier_id"
)
sys
.
exit
(
"can't query the correct supplier id."
)
handle_hk_csv
(
extract_dir
+
handle_file_name_1
,
conf_environment
,
rs_hk_supplier_id
)
#
handle_hk_csv(extract_dir + handle_file_name_1, conf_environment, rs_hk_supplier_id)
handle_cn_csv
(
extract_dir
+
handle_file_name_3
,
conf_environment
,
rs_cn_supplier_id
)
except
Exception
as
e
:
remove_file
(
extract_dir
)
logger
.
error
(
"报错:{}, 重试"
.
format
(
e
))
ftp_client
=
ftp
.
FTPUtil
(
host
=
conf_environment
[
"ftp"
][
"host"
],
port
=
conf_environment
[
"ftp"
][
"port"
],
passive
=
True
,
username
=
conf_environment
[
"ftp"
][
"username"
],
password
=
conf_environment
[
"ftp"
][
"password"
],
logger
=
logger
)
down_and_handle
(
ftp_client
)
return
extract_dir
...
...
utils/ftp.py
View file @
66f5e99e
import
ftplib
from
ftplib
import
FTP
import
os
...
...
@@ -13,11 +13,11 @@ class FTPUtil:
username
=
""
,
password
=
""
,
logger
):
ftp
=
ftplib
.
FTP
()
ftp
.
connect
(
host
,
port
)
ftp
.
login
(
username
,
password
)
ftp
.
set_pasv
(
passive
)
self
.
ftp
=
ftp
#
ftp = ftplib.FTP()
#
ftp.connect(host, port)
#
ftp.login(username, password)
#
ftp.set_pasv(passive)
self
.
ftp
=
FTP
(
host
,
username
,
password
,
timeout
=
60
)
self
.
logger
=
logger
def
get_connection
(
self
):
...
...
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