File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import os
44import sys
55from datetime import datetime
6+ from pathlib import Path
67
78import jsonpickle
89import 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
You can’t perform that action at this time.
0 commit comments