@@ -58,7 +58,7 @@ def update_preferences(keys: list[str]) -> list[str]:
5858 username = key .split ('/' )[2 ]
5959 with RunAs (username ):
6060 web .ctx .site .save (new_prefs , 'Updating preferences' )
61- except infogami .infobase .client .ClientException :
61+ except ( infogami .infobase .client .ClientException , KeyError , IndexError ) :
6262 retry_list .append (key )
6363
6464 return retry_list
@@ -78,21 +78,24 @@ def main(args):
7878
7979 print ("Updating preferences in batches of 1,000..." )
8080 batch_count = 1
81+ error_cases = []
8182 while affected_keys and not was_shutdown_requested ():
8283 print (f" Beginning batch #{ batch_count } ..." )
8384 cur_batch = affected_keys [:1000 ]
8485 affected_keys = affected_keys [1000 :]
8586 keys_to_retry = update_preferences (cur_batch )
86- affected_keys .extend (keys_to_retry )
87+ error_cases .extend (keys_to_retry )
8788 batch_count += 1
8889 print (f"{ len (keys_to_retry )} keys have been added to the retry queue." )
8990
91+ print ("\n All keys processed" )
92+ print (f"{ len (error_cases )} key(s) could not be updated." )
93+ for key in error_cases :
94+ print (key )
9095 if was_shutdown_requested ():
9196 print ("Script terminated early due to shutdown request" )
9297 return
9398
94- print ("All affected preferences have been updated." )
95-
9699
97100def _parse_args ():
98101 p = argparse .ArgumentParser (description = __doc__ )
0 commit comments