borgend.py

changeset 46
ecb41072a1b7
parent 45
aa2a95dc6093
child 49
db33dfa64ad6
equal deleted inserted replaced
45:aa2a95dc6093 46:ecb41072a1b7
62 fifolog.setFormatter(logging.Formatter(fifolog_fmt)) 62 fifolog.setFormatter(logging.Formatter(fifolog_fmt))
63 63
64 if __name__=="__main__": 64 if __name__=="__main__":
65 # Parse args. Let argparse handle errors/exit if there are any 65 # Parse args. Let argparse handle errors/exit if there are any
66 args= do_args() 66 args= do_args()
67 tray = None
67 68
68 try: 69 try:
69 args=do_args() 70 args=do_args()
70 71
71 if not os.path.isdir(config.logs_dir): 72 if not os.path.isdir(config.logs_dir):
83 import signal, os 84 import signal, os
84 85
85 backupconfigs=config.settings['backups'] 86 backupconfigs=config.settings['backups']
86 backups=[None]*len(backupconfigs); 87 backups=[None]*len(backupconfigs);
87 88
88 for i in range(len(backupconfigs)): 89 try:
89 logger.info('Setting up backup set %d' % i) 90 for i in range(len(backupconfigs)):
90 backups[i]=Backup(i, backupconfigs[i]) 91 logger.info('Setting up backup set %d' % i)
91 backups[i].schedule() 92 backups[i]=Backup(i, backupconfigs[i])
93 backups[i].schedule()
92 94
93 if args.notray or platform.system()!='Darwin': 95 if args.notray or platform.system()!='Darwin':
94 pass 96 pass
95 else: 97 else:
96 from ui import BorgendTray 98 from ui import BorgendTray
97 tray=BorgendTray(backups); 99 tray=BorgendTray(backups);
98 tray.run() 100 tray.run()
99 101 finally:
102 for i in range(len(backups)):
103 if backups[i]:
104 backups[i].abort()
105 backups=[]
100 except Exception as err: 106 except Exception as err:
101 utils.log_exception(logger, err, detail='Exiting') 107 utils.log_exception(logger, err, detail='Exiting')
102 logging.shutdown() 108 if tray:
103 os.exit() 109 tray.quit()
110 else:
111 logging.shutdown()
112 #sys.exit()
104 113
105 # 114 #
106 # This shit is fucked, disables ^C etc., and threading doesn't seem to help 115 # This shit is fucked, disables ^C etc., and threading doesn't seem to help
107 # 116 #
108 117

mercurial