From f96b2bc15094baf5998f82da2eb688a428a86f47 Mon Sep 17 00:00:00 2001 From: Abeautifulsnow <1491444340@qq.com> Date: Tue, 2 Nov 2021 17:04:37 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20bug:=20=E6=96=B0=E6=97=A7host=E6=AF=94?= =?UTF-8?q?=E5=AF=B9=E5=86=85=E5=AE=B9=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fetch_ips.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fetch_ips.py b/fetch_ips.py index 4c68d5a6..777d8396 100644 --- a/fetch_ips.py +++ b/fetch_ips.py @@ -68,13 +68,15 @@ def write_file(hosts_content: str, update_time: str): template_path = os.path.join(os.path.dirname(__file__), "README_template.md") write_host_file(hosts_content) - with open(output_doc_file_path, "r") as old_readme_fb: - old_content = old_readme_fb.read() - old_hosts = old_content.split("```bash")[1].split("```")[0].strip() - old_hosts = old_hosts.split("# Update time:")[0] - if old_hosts == hosts_content: - print("host not change") - return False + if os.path.exists(output_doc_file_path): + with open(output_doc_file_path, "r") as old_readme_fb: + old_content = old_readme_fb.read() + old_hosts = old_content.split("```bash")[1].split("```")[0].strip() + old_hosts = old_hosts.split("# Update time:")[0].strip() + hosts_content_hosts = hosts_content.split("# Update time:")[0].strip() + if old_hosts == hosts_content_hosts: + print("host not change") + return False with open(template_path, "r") as temp_fb: template_str = temp_fb.read()