Move borgend.py as borgend/___main__.py

Sun, 05 Dec 2021 13:09:12 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 05 Dec 2021 13:09:12 +0200
changeset 134
a7aa8ca7b3d0
parent 133
ec8014a2ee7a
child 135
45c1a38f8709

Move borgend.py as borgend/___main__.py

README.md file | annotate | diff | comparison | revisions
borgend.py file | annotate | diff | comparison | revisions
borgend/__main__.py file | annotate | diff | comparison | revisions
--- a/README.md	Sun Dec 05 00:42:01 2021 +0200
+++ b/README.md	Sun Dec 05 13:09:12 2021 +0200
@@ -51,7 +51,7 @@
 With the dependencies satisfied, and Borgend downloaded, it may be run from
 its download location with
 
-    python3 borgend.py
+    python3 borgend
 
 Before this, you will probably, however, want to create a configuration file as detailed below.
 
--- a/borgend.py	Sun Dec 05 00:42:01 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-#!/usr/local/bin/python3
-#
-# Borgend by Tuomo Valkonen, 2018
-#
-
-# Common modules
-import os
-import sys
-import argparse
-import platform
-import logging
-# Own modules needed at this stage
-import borgend.branding as branding
-import borgend.locations as locations
-
-#
-# Argument processing
-#
-
-epilog_format="""
-Configuration file location:
-
-    %s
-
-Log directory:
-
-    %s/
- """
-
-parser=argparse.ArgumentParser(
-    description=branding.appname_stylised + ": BorgBackup scheduler, queue, and tray icon.",
-    epilog=epilog_format % (locations.cfgfile, locations.logs_dir),
-    formatter_class=argparse.RawDescriptionHelpFormatter)
-
-parser.add_argument(
-    '--no-tray',
-    dest='notray',
-    action='store_true',
-    help='Do not show the tray icon')
-
-parser.add_argument(
-    '--debug',
-    dest='debug',
-    action='store_true',
-    help='Set logging level to debug')
-
-args=parser.parse_args()
-
-#
-# Done parsing args, import our own modules, and launch everything
-#
-
-import borgend.config as config
-import borgend.dreamtime as dreamtime
-import borgend.loggers as loggers
-from borgend.scheduler import Scheduler
-from borgend.repository import Repository
-from borgend.backup import Backup
-
-logger=loggers.mainlogger
-
-if args.debug:
-    logger.setLevel(logging.DEBUG)
-
-tray = None
-repos=[]
-backups=[]
-
-try:
-    dreamtime.start_monitoring()
-
-    scheduler = Scheduler()
-    scheduler.start()
-
-    repoconfigs=config.settings['repositories']
-
-    logger.info('Initialising repositories')
-    for i in range(len(repoconfigs)):
-        r=Repository(i, repoconfigs[i])
-        repos.append(r)
-
-    backupconfigs=config.settings['backups']
-
-    logger.info('Initialising backups')
-    for i in range(len(backupconfigs)):
-        b=Backup(i, backupconfigs[i], scheduler)
-        backups.append(b)
-
-    if args.notray or platform.system()!='Darwin':
-        # Wait for scheduler to finish
-        run=scheduler.join
-    else:
-        # This is needed for Ctrl+C to work.
-        # TODO: proper exit handler, which seems to require
-        # ditching/forking/extending rumps to extend the NSApp class
-        from PyObjCTools.AppHelper import installMachInterrupt
-        installMachInterrupt()
-        # Start UI, and let it handle exit control
-        from borgend.ui import BorgendTray
-        tray=BorgendTray(backups);
-        run=tray.run
-
-    for r in repos:
-        r.start()
-
-    for b in backups:
-        b.start()
-
-    run()
-
-except Exception as err:
-    # TODO: Should write errors here to stderr;
-    # perhaps add an extra stderr logger for error level messages
-    logger.exception("Exception fell through: exiting")
-
-finally:
-    logger.debug("Exiting")
-
-    for b in backups:
-        b.terminate()
-
-    for r in repos:
-        r.terminate()
-
-    if tray:
-        tray.quit()
-    else:
-        logging.shutdown()
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/borgend/__main__.py	Sun Dec 05 13:09:12 2021 +0200
@@ -0,0 +1,129 @@
+#!/usr/local/bin/python3
+#
+# Borgend by Tuomo Valkonen, 2018
+#
+
+# Common modules
+import os
+import sys
+import argparse
+import platform
+import logging
+# Own modules needed at this stage
+import borgend.branding as branding
+import borgend.locations as locations
+
+#
+# Argument processing
+#
+
+epilog_format="""
+Configuration file location:
+
+    %s
+
+Log directory:
+
+    %s/
+ """
+
+parser=argparse.ArgumentParser(
+    description=branding.appname_stylised + ": BorgBackup scheduler, queue, and tray icon.",
+    epilog=epilog_format % (locations.cfgfile, locations.logs_dir),
+    formatter_class=argparse.RawDescriptionHelpFormatter)
+
+parser.add_argument(
+    '--no-tray',
+    dest='notray',
+    action='store_true',
+    help='Do not show the tray icon')
+
+parser.add_argument(
+    '--debug',
+    dest='debug',
+    action='store_true',
+    help='Set logging level to debug')
+
+args=parser.parse_args()
+
+#
+# Done parsing args, import our own modules, and launch everything
+#
+
+import borgend.config as config
+import borgend.dreamtime as dreamtime
+import borgend.loggers as loggers
+from borgend.scheduler import Scheduler
+from borgend.repository import Repository
+from borgend.backup import Backup
+
+logger=loggers.mainlogger
+
+if args.debug:
+    logger.setLevel(logging.DEBUG)
+
+tray = None
+repos=[]
+backups=[]
+
+try:
+    dreamtime.start_monitoring()
+
+    scheduler = Scheduler()
+    scheduler.start()
+
+    repoconfigs=config.settings['repositories']
+
+    logger.info('Initialising repositories')
+    for i in range(len(repoconfigs)):
+        r=Repository(i, repoconfigs[i])
+        repos.append(r)
+
+    backupconfigs=config.settings['backups']
+
+    logger.info('Initialising backups')
+    for i in range(len(backupconfigs)):
+        b=Backup(i, backupconfigs[i], scheduler)
+        backups.append(b)
+
+    if args.notray or platform.system()!='Darwin':
+        # Wait for scheduler to finish
+        run=scheduler.join
+    else:
+        # This is needed for Ctrl+C to work.
+        # TODO: proper exit handler, which seems to require
+        # ditching/forking/extending rumps to extend the NSApp class
+        from PyObjCTools.AppHelper import installMachInterrupt
+        installMachInterrupt()
+        # Start UI, and let it handle exit control
+        from borgend.ui import BorgendTray
+        tray=BorgendTray(backups);
+        run=tray.run
+
+    for r in repos:
+        r.start()
+
+    for b in backups:
+        b.start()
+
+    run()
+
+except Exception as err:
+    # TODO: Should write errors here to stderr;
+    # perhaps add an extra stderr logger for error level messages
+    logger.exception("Exception fell through: exiting")
+
+finally:
+    logger.debug("Exiting")
+
+    for b in backups:
+        b.terminate()
+
+    for r in repos:
+        r.terminate()
+
+    if tray:
+        tray.quit()
+    else:
+        logging.shutdown()
+

mercurial