12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/usr/bin/python
- from __future__ import print_function
- import daemon
- import logging
- import sys
- import time
- import ffstatus
- LOGFILE = '/var/log/ffstatus.log'
- logging.basicConfig(
- filename=LOGFILE,
- format='%(asctime)s [%(levelname)s] %(message)s',
- datefmt='%Y-%m-%d %H:%M:%S',
- level=logging.INFO,
- )
- a = ffstatus.AlfredParser()
- try:
- a.sanitycheck()
- except Exception as err:
- logging.critical("Failed sanity-check: " + str(err))
- print('FAILED SANITY CHECK: ' + str(err))
- sys.exit(1)
- daemon_context = daemon.DaemonContext(
- files_preserve=[handler.stream]
- )
- with daemon_context:
- while True:
- try:
- logging.debug('Execute')
- a.execute()
- time.sleep(15)
- except Exception as err:
- logging.error(str(err))
|