# HG changeset patch # User Tuomo Valkonen # Date 1516546616 0 # Node ID 91421eeb44263563b39525ce35cc75a8f0fc878b # Parent 06fc14211ba935a7a925ea405c28ba5fc2863f9a Use rumps.application_support instead of xdg paths. Also separated branding into config.py diff -r 06fc14211ba9 -r 91421eeb4426 README.md --- a/README.md Sun Jan 21 14:34:35 2018 +0000 +++ b/README.md Sun Jan 21 14:56:56 2018 +0000 @@ -9,13 +9,14 @@ You will need to install the following non-standard Python packages: - [rumps](https://github.com/jaredks/rumps) (Ridiculously Uncomplicated macOS Python Statusbar apps) - - [keyring](https://pypi.python.org/pypi/keyring) + - [keyring](https://pypi.python.org/pypi/keyring) to extracdt passphrases from the keychain + For passphrase use authentication to work correctly, it is useful to create a standalone Mac app. This can be don with `py2app`. You can install it with pip install py2app -(for alternatives see [py2app documentation](https://py2app.readthedocs.io/en/latest/install.html#installing-with-pip)). Then, to build the standalone app, run +(for alternatives see [py2app documentation](https://py2app.readthedocs.io/en/latest/install.html)). Then, to build the standalone app, run python3 setup.py py2app diff -r 06fc14211ba9 -r 91421eeb4426 borgend.py --- a/borgend.py Sun Jan 21 14:34:35 2018 +0000 +++ b/borgend.py Sun Jan 21 14:56:56 2018 +0000 @@ -25,7 +25,7 @@ if __name__ == "__main__": #print(settings) - tray=BorgendTray("Borgend", backups); + tray=BorgendTray(backups); tray.run() pass diff -r 06fc14211ba9 -r 91421eeb4426 config.py --- a/config.py Sun Jan 21 14:34:35 2018 +0000 +++ b/config.py Sun Jan 21 14:56:56 2018 +0000 @@ -6,7 +6,6 @@ import yaml import io import os -import xdg import string import logging from functools import reduce @@ -37,6 +36,26 @@ } } +# +# Branding +# + +appname="borgend" +appname_stylised="Borgend" + +# +# Locations +# + +if False: + import xdg + cfgfile=os.path.join(xdg.XDG_CONFIG_HOME, appname, "config.yaml") + logs_location=os.path.join(xdg.XDG_DATA_HOME, appname, "logs") +else: + import rumps + __base=rumps.application_support(appname) + cfgfile=os.path.join(__base, "config.yaml") + logs_location=os.path.join(__base, "logs") # # Type checking etc. @@ -124,12 +143,10 @@ return out -cfgfile=os.path.join(xdg.XDG_CONFIG_HOME, "borgend", "config.yaml") +if not (os.path.exists(cfgfile) and os.path.isfile(cfgfile)): + raise SystemExit("Configuration file required: %s" % cfgfile) -logger.info("Reading configuration file %s" % cfgfile) - -if not (os.path.exists(cfgfile) and os.path.isfile(cfgfile)): - raise SystemExit('Configuration file required: {cfgfile}') +logger.info("Reading configuration %s missing" % cfgfile) with io.open(cfgfile, 'r') as file: settings=expand_env(yaml.load(file), os.environ); diff -r 06fc14211ba9 -r 91421eeb4426 setup.py --- a/setup.py Sun Jan 21 14:34:35 2018 +0000 +++ b/setup.py Sun Jan 21 14:56:56 2018 +0000 @@ -7,7 +7,7 @@ 'plist': { 'LSUIElement': True, }, - 'packages': ['rumps', 'keyring'], + 'packages': ['rumps', 'keyring'], #, 'xdg'], } setup( diff -r 06fc14211ba9 -r 91421eeb4426 ui.py --- a/ui.py Sun Jan 21 14:34:35 2018 +0000 +++ b/ui.py Sun Jan 21 14:56:56 2018 +0000 @@ -7,7 +7,7 @@ import datetime import logging from threading import Lock, Timer -from config import settings +from config import settings, appname_stylised import objc logger=logging.getLogger(__name__) @@ -106,7 +106,7 @@ class BorgendTray(rumps.App): - def __init__(self, name, backups): + def __init__(self, backups): self.lock=Lock() self.backups=backups self.statuses=[None]*len(backups) @@ -180,7 +180,8 @@ logger.debug("Opening notification for error %s '%s'", msgid, errorlog['message']) - notification_workaround('Borgend', msgid, errorlog['message']) + notification_workaround(appname_stylised, + msgid, errorlog['message']) def my_quit(self, _): rumps.quit_application() @@ -193,7 +194,8 @@ except Exception as err: logger.debug("Opening notification for exception %s '%s'", err.__class__.__name__, str(err)) - notification_workaround('Borgend', err.__class__.__name__, str(err)) + notification_workaround(appname_stylised, + err.__class__.__name__, str(err)) @rumps.notifications def notification_center(data):