job_storage.py 438 B

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