11 from bunch import Bunch
13 def handle_interrupt(sig, frame):
15 if os.getpid() == main_pid:
16 logging.info( "Got stop signal." )
19 main_pid = os.getpid()
20 signal.signal(signal.SIGINT, handle_interrupt)
23 parser = argparse.ArgumentParser(description='Photo Sort Daemon.')
24 parser.add_argument('config_file', type=str, help='path to config file')
25 parser.add_argument('-l', '--log-level', type=str, default='INFO', dest='log_lvl',
26 choices=['DEBUG', 'INFO', 'WARNING'], help='select log level')
28 args = parser.parse_args()
30 logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s',
31 level=logging.getLevelName(args.log_lvl),
32 datefmt='%m/%d/%Y %H:%M:%S')
36 with open(args.config_file) as f:
40 for bunch_cfg in cfg['bunches']:
41 bunches.append( Bunch(bunch_cfg) )
48 if not bunch.is_running():