10 from bunch import Bunch
12 def handle_interrupt(sig, frame):
14 if os.getpid() == main_pid:
15 logging.info( "Got stop signal." )
18 main_pid = os.getpid()
19 signal.signal(signal.SIGINT, handle_interrupt)
22 parser = argparse.ArgumentParser(description='Photo Sort Daemon.')
23 parser.add_argument('config_file', type=str, help='path to config file')
24 parser.add_argument('-l', '--log-level', type=str, default='INFO', dest='log_lvl',
25 choices=['DEBUG', 'INFO', 'WARNING'], help='select log level')
27 args = parser.parse_args()
29 logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s',
30 level=logging.getLevelName(args.log_lvl),
31 datefmt='%m/%d/%Y %H:%M:%S')
33 with open(args.config_file) as f:
37 for bunch_cfg in cfg['bunches']:
38 bunches.append( Bunch(bunch_cfg) )