From cae1132c6ee4be0e780f361c39f1cdc5a31f27bb Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Mon, 15 Apr 2024 12:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E5=BA=94=E6=A0=B9=E6=8D=AE=E9=9C=80=E8=A6=81=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=90=88=E9=80=82=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- tool/update_tool/download_iana.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tool/update_tool/download_iana.py b/tool/update_tool/download_iana.py index 28b1d17..c0f4744 100644 --- a/tool/update_tool/download_iana.py +++ b/tool/update_tool/download_iana.py @@ -23,10 +23,13 @@ import ssl import tarfile import sys import os +import stat def find_current_version(path): - with open(path, 'r') as file: + flags = os.O_RDONLY + modes = stat.S_IWUSR | stat.S_IRUSR + with os.fdopen(os.open(path, flags, modes), 'r') as file: version = file.readline().strip() return version @@ -45,7 +48,9 @@ def try_download(file_type, try_version, save_path, version): print('start to download ' + file_name) content = data.read() data.close() - with open(save_path + file_name, 'wb+') as file: + flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL + modes = stat.S_IWUSR | stat.S_IRUSR + with os.fdopen(os.open(save_path + file_name, flags, modes), 'wb+') as file: file.write(content) print('download finished!') return 1 -- Gitee