@@ -224,17 +224,14 @@ def update_images():
224224
225225def get_monthly_pulls ():
226226 pulls_map = {}
227- try :
228- response = requests .get ("https://api.scarf.sh/v2/packages/linuxserver-ci/overview?per_page=1000" , headers = {"Authorization" : f"Bearer { SCARF_TOKEN } " })
229- results = response .json ()["results" ]
230- for result in results :
231- name = result ["package" ]["name" ].replace ("linuxserver/" , "" )
232- if "total_installs" not in result :
233- continue
234- monthly_pulls = result ["total_installs" ]
235- pulls_map [name ] = monthly_pulls
236- except Exception :
237- print (traceback .format_exc ())
227+ response = requests .get ("https://api.scarf.sh/v2/packages/linuxserver-ci/overview?per_page=1000" , headers = {"Authorization" : f"Bearer { SCARF_TOKEN } " })
228+ results = response .json ()["results" ]
229+ for result in results :
230+ name = result ["package" ]["name" ].replace ("linuxserver/" , "" )
231+ if "total_installs" not in result :
232+ continue
233+ monthly_pulls = result ["total_installs" ]
234+ pulls_map [name ] = monthly_pulls
238235 return pulls_map
239236
240237def update_scarf ():
@@ -250,15 +247,26 @@ def update_scarf():
250247 new_state = json .dumps (pulls_map )
251248 kv .set_value ("scarf" , new_state , SCARF_SCHEMA_VERSION )
252249 print (f"{ datetime .datetime .now ()} - updated scarf" )
253-
250+
251+ def update_status (status ):
252+ with KeyValueStore (invalidate_hours = 0 , readonly = False ) as kv :
253+ print (f"{ datetime .datetime .now ()} - updating status" )
254+ kv .set_value ("status" , status , 0 )
255+ print (f"{ datetime .datetime .now ()} - updated status" )
254256
255257def main ():
256- set_db_schema ()
257- while True :
258- gh .print_rate_limit ()
259- update_scarf ()
260- update_images ()
261- gh .print_rate_limit ()
258+ try :
259+ set_db_schema ()
260+ while True :
261+ gh .print_rate_limit ()
262+ update_scarf ()
263+ update_images ()
264+ gh .print_rate_limit ()
265+ update_status ("Success" )
266+ time .sleep (INVALIDATE_HOURS * 60 * 60 )
267+ except :
268+ print (traceback .format_exc ())
269+ update_status ("Failed" )
262270 time .sleep (INVALIDATE_HOURS * 60 * 60 )
263271
264272if __name__ == "__main__" :
0 commit comments