borgend.py

changeset 49
db33dfa64ad6
parent 46
ecb41072a1b7
child 50
2d8947351727
--- a/borgend.py	Mon Jan 22 12:04:19 2018 +0000
+++ b/borgend.py	Mon Jan 22 18:16:51 2018 +0000
@@ -7,7 +7,6 @@
 import argparse
 import platform
 import utils
-from fifolog import FIFOHandler
 
 #
 # Branding
@@ -30,14 +29,23 @@
 
 logger=logging.getLogger(appname)
 logger.setLevel(loglevel)
+stderrlog=logging.StreamHandler()
+logger.addHandler(stderrlog)
 logger.propagate=True
 
 #
+# Import our own modules. This needs to be done here
+# for the things above to be available to them
+#
+
+import config
+from scheduler import Scheduler
+from fifolog import FIFOHandler
+
+#
 # Argument processing
 #
 
-import config
-
 def do_args():
     parser=argparse.ArgumentParser(
         description=appname_stylised + ': BorgBackup scheduler and tray icon.',
@@ -86,11 +94,15 @@
         backupconfigs=config.settings['backups']
         backups=[None]*len(backupconfigs);
 
+        scheduler = Scheduler()
+
         try:
+            scheduler.start()
+
             for i in range(len(backupconfigs)):
                 logger.info('Setting up backup set %d' % i)
-                backups[i]=Backup(i, backupconfigs[i])
-                backups[i].schedule()
+                backups[i]=Backup(i, backupconfigs[i], scheduler)
+                backups[i].start()
 
             if args.notray or platform.system()!='Darwin':
                 pass
@@ -104,6 +116,8 @@
                     backups[i].abort()
             backups=[]
     except Exception as err:
+        # TODO: Should write errors here to stderr;
+        # perhaps add an extra stderr logger for error level messages
         utils.log_exception(logger, err, detail='Exiting')
         if tray:
             tray.quit()

mercurial