job_storage.py 468 B

1234567891011121314151617181920
  1. """read resource jobs"""
  2. import sys
  3. import json
  4. from app import LOGGER
  5. def get_jobs():
  6. """Read jobs"""
  7. LOGGER.info('Read stored jobs')
  8. try:
  9. with open('jobs.json', 'r') as jobs_file:
  10. jobs = json.load(jobs_file)
  11. LOGGER.info('found "%s" job(s) in job storage', len(jobs))
  12. return jobs
  13. except FileNotFoundError:
  14. LOGGER.error('job storage file "jobs.json" not found')
  15. sys.exit(1)
  16. return []