daemon_process.py 813 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. import json
  3. from notify import notify
  4. from time import sleep
  5. import os
  6. os.system('./run_spider.sh')
  7. with open('./date.json') as json_data:
  8. file_content = json.load(json_data)
  9. curr_date = file_content[0]['date']
  10. while True:
  11. os.system('./run_spider.sh')
  12. with open('./date.json') as json_data:
  13. file_content = json.load(json_data)
  14. new_date = file_content[0]['date']
  15. month = int(new_date.split('-')[1])
  16. day = int(new_date.split('-')[2])
  17. # Less than 2nd may and later than 11th april.
  18. #
  19. if ((month == 5 and day < 2) or (month == 4 and day >= 11)) and (new_date != curr_date):
  20. notify('New date!\n' + new_date)
  21. curr_date = new_date
  22. # Sleep for 6 min.
  23. #
  24. sleep(360)
  25. # EOF
  26. # vim: set tabstop=4 shiftwidth=4 expandtab :