code: def collect_jobs(dirs, runscript, overwrite=False, max_job_age=90):
      
  
      jobs = []
  
      for dirname in sorted(dirs):
  
          o = dict(cfgfile=os.path.join(dirname, 'config.yaml'),
                   logfile=os.path.join(
                       dirname, os.path.splitext(runscript)[0] + '.log'),
                   runscript=os.path.join(dirname, runscript))
  
          if not os.path.isfile(o['cfgfile']):
              continue
  
          if not os.path.isfile(o['runscript']):
              continue
  
          if not os.path.isfile(o['logfile']):
              jobs.append(o)
              continue
  
          age = file_age_in_seconds(o['logfile']) / 60.
          job_status = check_log(o['logfile'])
  
          print(dirname, job_status, age)
  
          if job_status is False or overwrite:
              jobs.append(o)
          elif job_status == 'Exited':
              print("Job Exited. Resending command.")
              jobs.append(o)
          elif job_status == 'None' and age > max_job_age:
              print(
                  "Job did not exit, but no activity on log file for > %.2f min. Resending command." % max_job_age)
              jobs.append(o)
          #        elif job_status is True:
          #            print("Job Completed. Resending command.")
          #            jobs.append(o)
  
      return jobs
docs: Construct a list of job dictionaries.