Skip to content

Commit b0b0383

Browse files
authored
Merge pull request #225 from AnguseZhang/chore/update-scripts
refactor: use pathlib for file existence check and update error loggi…
2 parents 67ab8dc + ed320eb commit b0b0383

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

scripts/get_acs_result.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import sys
55
from datetime import datetime
6+
from pathlib import Path
67

78
import jsonpickle
89
import requests
@@ -70,16 +71,15 @@ def download_file(response, output_path):
7071
logger.error(f'`{file_download_path}` url returned 400 Bad Request')
7172
elif status_code == 200:
7273
download_file(response, file_download_path)
73-
if (
74-
os.path.exists(file_download_path)
75-
and os.path.getsize(file_download_path) > 0
76-
):
74+
if Path(file_download_path).exists():
7775
file_size = os.path.getsize(file_download_path)
7876
logger.info(
7977
f"Download `{file_download_path}` completed successfully! File size: {file_size} bytes"
8078
)
8179
else:
82-
logger.error("Error: Download failed - file is empty or doesn't exist")
80+
logger.error(
81+
f"Error: Download `{file_download_path}` failed - file doesn't exist"
82+
)
8383
else:
8484
logger.error(f'`{file_download_path}` url returned status code: {status_code}')
8585

0 commit comments

Comments
 (0)