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
b11a0c65
authored
Jun 19, 2025
by
刘豪
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加重试
parent
e0e96851
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
16 deletions
rs_data.py
rs_data.py
View file @
b11a0c65
...
...
@@ -195,21 +195,7 @@ def get_supplier_id(supplier_name: str, conf: dict) -> int:
return
supplier_id
if
__name__
==
'__main__'
:
environment
=
sys
.
argv
[
1
]
if
environment
not
in
{
"local"
,
"dev"
,
"prod"
}:
sys
.
exit
(
"param error!"
)
conf_environment
=
conf
[
environment
]
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
)
if
not
os
.
path
.
exists
(
conf_environment
[
"tmp_file_path"
]):
os
.
makedirs
(
conf_environment
[
"tmp_file_path"
])
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
)
...
...
@@ -236,16 +222,45 @@ if __name__ == '__main__':
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
:
logger
.
error
(
"报错:{}"
.
format
(
e
))
logger
.
error
(
"报错:{}, 重试"
.
format
(
e
))
down_and_handle
(
ftp_client
)
return
extract_dir
def
remove_file
(
extract_dir
):
"""remove the temp file, close the connection"""
logger
.
info
(
"删除压缩包"
)
remove
(
extract_dir
+
handle_file_name_1
)
remove
(
extract_dir
+
handle_file_name_3
)
remove
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_1
)
remove
(
conf_environment
[
"tmp_file_path"
]
+
local_file_name_3
)
def
run
():
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
)
if
not
os
.
path
.
exists
(
conf_environment
[
"tmp_file_path"
]):
os
.
makedirs
(
conf_environment
[
"tmp_file_path"
])
extract_dir
=
down_and_handle
(
ftp_client
)
remove_file
(
extract_dir
)
logger
.
info
(
"运行完成"
)
if
__name__
==
'__main__'
:
environment
=
sys
.
argv
[
1
]
if
environment
not
in
{
"local"
,
"dev"
,
"prod"
}:
sys
.
exit
(
"param error!"
)
conf_environment
=
conf
[
environment
]
run
()
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