__main__.py 710 B

123456789101112131415161718192021222324252627282930313233
  1. """Main app"""
  2. import sys
  3. import time
  4. from app import SCHEDULER, LOGGER, jobs, job_storage
  5. if __name__ == '__main__':
  6. # jobs
  7. # jobs.update_regions(2981)
  8. # sys.exit()
  9. # Jobs
  10. JOBS = job_storage.get_jobs()
  11. for state_id in JOBS:
  12. LOGGER.info('"%s" add update job', state_id,)
  13. SCHEDULER.add_job(
  14. jobs.update_regions,
  15. 'cron',
  16. args=[state_id],
  17. id='{}_update_regions'.format(state_id),
  18. replace_existing=True,
  19. hour='12'
  20. )
  21. try:
  22. while True:
  23. time.sleep(100)
  24. except KeyboardInterrupt:
  25. print('Exiting application')
  26. SCHEDULER.shutdown()
  27. sys.exit()