from configuration import iers_download_url,iers_output_dir import urllib.request import os download_filenames = [ 'finals.daily', 'finals.daily.extended', 'finals2000A.daily', 'finals2000A.daily.extended' ] os.makedirs(iers_output_dir, exist_ok=True) for filename in download_filenames: url = os.path.join(iers_download_url, filename) final_path = os.path.join(iers_output_dir, filename) temp_path = final_path + '.temp' try: # download to temporary file urllib.request.urlretrieve(url, temp_path) # atomically replace the old file os.replace(temp_path, final_path) print(f"Downloaded {filename}") except Exception as e: # clean up partial download if os.path.exists(temp_path): os.remove(temp_path) print(f"Failed to download {filename}: {e}")