Skip to content
Snippets Groups Projects
retryFailedChecks.py 1.24 KiB
#!/usr/bin/env python3

import os
import eccs_properties as e_p
import utils

def get_idp_entityID(line):
    import json

    line = line.lstrip(f"{e_p.ECCS_DIR}/eccs.py '")
    line = line.rstrip("\'\n")
    json_line = json.loads(line)

    return json_line['entityID']

 
# MAIN
if __name__=="__main__":

   if (os.stat(e_p.ECCS_FAILEDCMD).st_size == 0):
      print(f"{e_p.DAY} - ECCS OK: All eduGAIN IdPs have been checked successfully.")
   else:
      with open(e_p.ECCS_FAILEDCMD) as f:

           # For each one, run ECCS check and remove its line
           # from the "failed-cmd.sh".
           for line in f:
               idp = get_idp_entityID(line)
               os.system(f'{line.rstrip()}')

               with open(f'{e_p.ECCS_OUTPUTDIR}/{e_p.ECCS_RESULTSLOG}') as o:
                    for line in o:
                        if (idp in line):
                           utils.delete_line_with_word(e_p.ECCS_FAILEDCMD,idp)
                           print(f"ECCS check retried successfully for {idp}")


      if (os.stat(e_p.ECCS_FAILEDCMD).st_size == 0):
         print(f"{e_p.DAY} - ECCS OK: All eduGAIN IdPs have been checked successfully.")
      else:
         print(f"{e_p.DAY} - Something went wrong. See the log files and failed-cmd.sh.")