borgend.py

changeset 40
cfbeeec8cb82
parent 39
56af43e9c949
child 41
e2641cb9ca6d
equal deleted inserted replaced
39:56af43e9c949 40:cfbeeec8cb82
29 logger.addHandler(fifolog) 29 logger.addHandler(fifolog)
30 fifolog.setFormatter(logging.Formatter(fifolog_fmt)) 30 fifolog.setFormatter(logging.Formatter(fifolog_fmt))
31 31
32 if __name__=="__main__": 32 if __name__=="__main__":
33 33
34 import logging.handlers 34 try:
35 import os 35 import logging.handlers
36 import config 36 import os
37 import config
37 38
38 if not os.path.isdir(config.logs_dir): 39 if not os.path.isdir(config.logs_dir):
39 os.makedirs(config.logs_dir) 40 os.makedirs(config.logs_dir)
40 41
41 handler=logging.handlers.TimedRotatingFileHandler( 42 handler=logging.handlers.TimedRotatingFileHandler(
42 os.path.join(config.logs_dir, appname+'.log'), 43 os.path.join(config.logs_dir, appname+'.log'),
43 when='D', interval=1) 44 when='D', interval=1)
44 handler.setFormatter(logging.Formatter(logfmt)) 45 handler.setFormatter(logging.Formatter(logfmt))
45 logger.addHandler(handler) 46 logger.addHandler(handler)
46 47
47 from threading import Thread 48 from threading import Thread
48 from backup import Backup 49 from backup import Backup
49 from queue import Queue 50 from queue import Queue
50 from ui import BorgendTray 51 from ui import BorgendTray
51 import signal, os 52 import signal, os
52 53
53 backupconfigs=config.settings['backups'] 54 backupconfigs=config.settings['backups']
54 backups=[None]*len(backupconfigs); 55 backups=[None]*len(backupconfigs);
55 56
56 for i in range(len(backupconfigs)): 57 for i in range(len(backupconfigs)):
57 logger.info('Setting up backup set %d' % i) 58 logger.info('Setting up backup set %d' % i)
58 backups[i]=Backup(i, backupconfigs[i]) 59 backups[i]=Backup(i, backupconfigs[i])
59 backups[i].schedule() 60 backups[i].schedule()
60 61
61 tray=BorgendTray(backups); 62 tray=BorgendTray(backups);
62 tray.run() 63 tray.run()
64 except Exception as err:
65 utils.log_exception(logger, err, detail='Exiting')
66 logging.shutdown()
63 67
64 # 68 #
65 # This shit is fucked, disables ^C etc., and threading doesn't seem to help 69 # This shit is fucked, disables ^C etc., and threading doesn't seem to help
66 # 70 #
67 71

mercurial