__main__.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Main app"""
  2. import sys
  3. import time
  4. from app import SCHEDULER, LOGGER, jobs
  5. if __name__ == '__main__':
  6. LOGGER.info('Starting application')
  7. # state to track citizens, residents, and work permits
  8. STATE_IDS = [
  9. 3304, # VN
  10. 3261, # Craftbroec
  11. ]
  12. # aditional regions to track citizens and residents
  13. REGION_IDS = [
  14. 4001, # Noord
  15. 4002, # Oost
  16. 4003, # West
  17. 4004, # Zuid
  18. 4008, # Amsterdam
  19. 4101, # Vlaanderen
  20. 4102, # Walonie
  21. 4103, # Brussel
  22. 200062, # Maan regio 62
  23. ]
  24. # jobs
  25. # jobs.update_citizens(STATE_IDS, REGION_IDS)
  26. # jobs.update_residents(STATE_IDS, REGION_IDS)
  27. # jobs.update_work_permits(STATE_IDS)
  28. # Update citizens
  29. SCHEDULER.add_job(
  30. jobs.update_citizens,
  31. 'cron',
  32. args=[STATE_IDS, REGION_IDS],
  33. id='update_citizens',
  34. replace_existing=True,
  35. hour='1,3,5,7,9,11,13,15,17,19,21,23'
  36. )
  37. # Update residents
  38. SCHEDULER.add_job(
  39. jobs.update_residents,
  40. 'cron',
  41. args=[STATE_IDS, REGION_IDS],
  42. id='residents',
  43. replace_existing=True,
  44. hour='1,4,7,10,13,16,19,22'
  45. )
  46. # Work permits
  47. SCHEDULER.add_job(
  48. jobs.update_work_permits,
  49. 'cron',
  50. args=[STATE_IDS],
  51. id='work_permits',
  52. replace_existing=True,
  53. hour='2,5,8,11,14,17,20,23'
  54. )
  55. try:
  56. while True:
  57. time.sleep(100)
  58. except KeyboardInterrupt:
  59. LOGGER.info('Exiting application')
  60. SCHEDULER.shutdown()
  61. sys.exit()