Sun, 21 Jan 2018 12:10:57 +0000
Added no_quit_menu_entry option
backup.py | file | annotate | diff | comparison | revisions | |
config.py | file | annotate | diff | comparison | revisions | |
ui.py | file | annotate | diff | comparison | revisions |
--- a/backup.py Sun Jan 21 12:04:24 2018 +0000 +++ b/backup.py Sun Jan 21 12:10:57 2018 +0000 @@ -76,7 +76,7 @@ 'Keychain account', self.loc, default='') - if config.settings['__extract_passphrases_at_startup']: + if config.settings['extract_passphrases_at_startup']: self.extract_passphrase() def extract_passphrase(self):
--- a/config.py Sun Jan 21 12:04:24 2018 +0000 +++ b/config.py Sun Jan 21 12:10:57 2018 +0000 @@ -22,7 +22,10 @@ # Default: retry every 15 minutes if unable to connect / unfinished backup 'retry_interval': 900, # Extract passphrases at startup or on demand? - '__extract_passphrases_at_startup': True, + 'extract_passphrases_at_startup': True, + # Do not insert a quit menu entry (useful for installing on computers of + # inexperienced users) + 'no_quit_menu_entry': False, # Borg settings 'borg': { 'executable': 'borg', @@ -40,6 +43,10 @@ def error(x): raise AssertionError(x) +def check_bool(cfg, field, descr, loc, default=None): + return check_field(cfg, field, descr, loc, default, + lambda x: isinstance(x, bool)) + def check_string(cfg, field, descr, loc, default=None): return check_field(cfg, field, descr, loc, default, lambda x: isinstance(x, str)) @@ -139,7 +146,8 @@ check_and_set(settings, 'backup_interval', 'top-level', defaults, check_nonneg_int) check_and_set(settings, 'retry_interval', 'top-level', defaults, check_nonneg_int) -check_and_set(settings, '__extract_passphrases_at_startup', 'top-level', defaults, check_nonneg_int) +check_and_set(settings, 'extract_passphrases_at_startup', 'top-level', defaults, check_nonneg_int) +check_and_set(settings, 'no_quit_menu_entry', 'top-level', defaults, check_bool) check_and_set(settings, 'borg', 'top-level', defaults, check_dict) # Check parameters within 'borg' if True:
--- a/ui.py Sun Jan 21 12:04:24 2018 +0000 +++ b/ui.py Sun Jan 21 12:10:57 2018 +0000 @@ -7,6 +7,7 @@ import datetime import logging from threading import Lock, Timer +from config import settings import objc INACTIVE=0 @@ -136,8 +137,9 @@ menu.append(item) state=combine_state(state, this_state) - menu_quit=rumps.MenuItem("Quit...", callback=self.my_quit) - menu.append(menu_quit) + if not settings['no_quit_menu_entry']: + menu_quit=rumps.MenuItem("Quit...", callback=self.my_quit) + menu.append(menu_quit) return menu, state