borgend.py

changeset 74
4f56142e7497
parent 73
4f0e9cf8f230
child 76
4b08fca3ce34
equal deleted inserted replaced
73:4f0e9cf8f230 74:4f56142e7497
40 # 40 #
41 41
42 import config 42 import config
43 from scheduler import Scheduler 43 from scheduler import Scheduler
44 from fifolog import FIFOHandler 44 from fifolog import FIFOHandler
45 from repository import Repository
45 46
46 # 47 #
47 # Argument processing 48 # Argument processing
48 # 49 #
49 50
78 79
79 if __name__=="__main__": 80 if __name__=="__main__":
80 # Parse args. Let argparse handle errors/exit if there are any 81 # Parse args. Let argparse handle errors/exit if there are any
81 args= do_args() 82 args= do_args()
82 tray = None 83 tray = None
84 repos=[]
83 backups=[] 85 backups=[]
84 86
85 try: 87 try:
86 args=do_args() 88 args=do_args()
87 89
103 import signal, os 105 import signal, os
104 106
105 scheduler = Scheduler() 107 scheduler = Scheduler()
106 scheduler.start() 108 scheduler.start()
107 109
110 repoconfigs=config.settings['repositories']
111
112 for i in range(len(repoconfigs)):
113 logger.info('Setting up repository %d' % i)
114 r=Repository(i, repoconfigs[i])
115 repos.append(r)
116
108 backupconfigs=config.settings['backups'] 117 backupconfigs=config.settings['backups']
109 118
110 for i in range(len(backupconfigs)): 119 for i in range(len(backupconfigs)):
111 logger.info('Setting up backup set %d' % i) 120 logger.info('Setting up backup set %d' % i)
112 b=Backup(i, backupconfigs[i], scheduler) 121 b=Backup(i, backupconfigs[i], scheduler)
113 backups.append(b) 122 backups.append(b)
123
124 for r in repos:
125 r.start()
114 126
115 for b in backups: 127 for b in backups:
116 b.start() 128 b.start()
117 129
118 if args.notray or platform.system()!='Darwin': 130 if args.notray or platform.system()!='Darwin':
131 143
132 finally: 144 finally:
133 for b in backups: 145 for b in backups:
134 b.terminate() 146 b.terminate()
135 147
148 for r in repos:
149 r.terminate()
150
136 if tray: 151 if tray:
137 tray.quit() 152 tray.quit()
138 else: 153 else:
139 logging.shutdown() 154 logging.shutdown()
140 155

mercurial