@@ -99,20 +99,35 @@ def _need_update() -> bool:
99
99
if pull_frequency_hours is not None :
100
100
update_frequency_str = f' (every { pull_frequency_hours } hours)'
101
101
with backend_utils .safe_console_status (
102
- f'Updating { cloud } catalog{ update_frequency_str } ' ):
102
+ (f'Updating { cloud } catalog: '
103
+ f'{ filename } '
104
+ f'{ update_frequency_str } ' )) as status :
103
105
try :
104
106
r = requests .get (url )
105
107
r .raise_for_status ()
106
108
except requests .exceptions .RequestException as e :
107
- logger .error (f'Failed to download { cloud } catalog:' )
108
- with ux_utils .print_exception_no_traceback ():
109
- raise e
110
- # Save the catalog to a local file.
111
- os .makedirs (os .path .dirname (catalog_path ), exist_ok = True )
112
- with open (catalog_path , 'w' ) as f :
113
- f .write (r .text )
114
- with open (meta_path + '.md5' , 'w' ) as f :
115
- f .write (hashlib .md5 (r .text .encode ()).hexdigest ())
109
+ ux_utils .console_newline ()
110
+ status .stop ()
111
+ error_str = (f'Failed to fetch { cloud } catalog '
112
+ f'{ filename } . ' )
113
+ if os .path .exists (catalog_path ):
114
+ logger .warning (
115
+ f'{ error_str } Using cached catalog files.' )
116
+ # Update catalog file modification time.
117
+ os .utime (catalog_path , None ) # Sets to current time
118
+ else :
119
+ logger .error (
120
+ f'{ error_str } Please check your internet connection.'
121
+ )
122
+ with ux_utils .print_exception_no_traceback ():
123
+ raise e
124
+ else :
125
+ # Download successful, save the catalog to a local file.
126
+ os .makedirs (os .path .dirname (catalog_path ), exist_ok = True )
127
+ with open (catalog_path , 'w' ) as f :
128
+ f .write (r .text )
129
+ with open (meta_path + '.md5' , 'w' ) as f :
130
+ f .write (hashlib .md5 (r .text .encode ()).hexdigest ())
116
131
117
132
try :
118
133
df = pd .read_csv (catalog_path )
0 commit comments