Sun, 21 Jan 2018 22:01:57 +0000
--no-tray command line option for running on non-MacOS systems
README.md | file | annotate | diff | comparison | revisions | |
borgend.py | file | annotate | diff | comparison | revisions |
--- a/README.md Sun Jan 21 21:32:48 2018 +0000 +++ b/README.md Sun Jan 21 22:01:57 2018 +0000 @@ -8,10 +8,13 @@ You will need to install the following non-standard Python packages: + - [keyring](https://pypi.python.org/pypi/keyring) to extract passphrases from the keychain + +The use the tray icon on Mac OS, you will need: + - [rumps](https://github.com/jaredks/rumps) (Ridiculously Uncomplicated macOS Python Statusbar apps) - - [keyring](https://pypi.python.org/pypi/keyring) to extracdt passphrases from the keychain -If you want to try to run Borgend without the Tray icon on other systems, you will also want: +If you are not on Mac OS, you will need: - [xdg](https://pypi.python.org/pypi/xdg/3.0.0) for configuration file location @@ -25,6 +28,7 @@ The apps hould be placed under `dist/`. + ## Usage and configuration ### Configuration file @@ -38,6 +42,10 @@ security add-generic-password -a my-borg-backup -s borg-backup -w [PASSWORD] +### Running on non-Mac OS systems + +You will need to start Borgend with the `--no-tray` option. + ## License
--- a/borgend.py Sun Jan 21 21:32:48 2018 +0000 +++ b/borgend.py Sun Jan 21 22:01:57 2018 +0000 @@ -1,6 +1,9 @@ #!/usr/local/bin/python3 +import os import logging +import logging.handlers +import argparse from fifolog import FIFOHandler # @@ -19,22 +22,48 @@ fifolog_fmt="%(asctime)s:%(levelname)s:%(message)s" # -# Setup logger +# Setup logger, needed by the config module to be loaded next # logger=logging.getLogger(appname) logger.setLevel(loglevel) logger.propagate=True + +# +# Argument processing +# + +import config + +def do_args(): + parser=argparse.ArgumentParser( + description=appname_stylised + ': BorgBackup scheduler and tray icon.', + epilog='Configuration file location:\n\n %s\n ' % config.cfgfile, + formatter_class=argparse.RawDescriptionHelpFormatter) + + parser.add_argument( + '--no-tray', + dest='notray', + action='store_true', + help='Do not show the tray icon') + + return parser.parse_args() + +# +# Main routine +# + +# First, setup our own logging handlers fifolog=FIFOHandler(fifolog_capacity) logger.addHandler(fifolog) fifolog.setFormatter(logging.Formatter(fifolog_fmt)) if __name__=="__main__": + # Parse args. Let argparse handle errors/exit if there are any + args= do_args() try: - import logging.handlers - import os - import config + args=do_args() if not os.path.isdir(config.logs_dir): os.makedirs(config.logs_dir) @@ -48,7 +77,6 @@ from threading import Thread from backup import Backup from queue import Queue - from ui import BorgendTray import signal, os backupconfigs=config.settings['backups'] @@ -59,8 +87,13 @@ backups[i]=Backup(i, backupconfigs[i]) backups[i].schedule() - tray=BorgendTray(backups); - tray.run() + if args.notray: + pass + else: + from ui import BorgendTray + tray=BorgendTray(backups); + tray.run() + except Exception as err: utils.log_exception(logger, err, detail='Exiting') logging.shutdown()