config.py

changeset 30
3dd525652dc8
parent 23
86b42610d5a8
child 31
b4b4bb7a2ec5
equal deleted inserted replaced
29:9dd2e5d57a7c 30:3dd525652dc8
20 # Default: backup every 6 hours (21600 seconds) 20 # Default: backup every 6 hours (21600 seconds)
21 'backup_interval': 21600, 21 'backup_interval': 21600,
22 # Default: retry every 15 minutes if unable to connect / unfinished backup 22 # Default: retry every 15 minutes if unable to connect / unfinished backup
23 'retry_interval': 900, 23 'retry_interval': 900,
24 # Extract passphrases at startup or on demand? 24 # Extract passphrases at startup or on demand?
25 '__extract_passphrases_at_startup': True, 25 'extract_passphrases_at_startup': True,
26 # Do not insert a quit menu entry (useful for installing on computers of
27 # inexperienced users)
28 'no_quit_menu_entry': False,
26 # Borg settings 29 # Borg settings
27 'borg': { 30 'borg': {
28 'executable': 'borg', 31 'executable': 'borg',
29 'common_parameters': [], 32 'common_parameters': [],
30 'create_parameters': [], 33 'create_parameters': [],
37 # Type checking etc. 40 # Type checking etc.
38 # 41 #
39 42
40 def error(x): 43 def error(x):
41 raise AssertionError(x) 44 raise AssertionError(x)
45
46 def check_bool(cfg, field, descr, loc, default=None):
47 return check_field(cfg, field, descr, loc, default,
48 lambda x: isinstance(x, bool))
42 49
43 def check_string(cfg, field, descr, loc, default=None): 50 def check_string(cfg, field, descr, loc, default=None):
44 return check_field(cfg, field, descr, loc, default, 51 return check_field(cfg, field, descr, loc, default,
45 lambda x: isinstance(x, str)) 52 lambda x: isinstance(x, str))
46 53
137 'borg', defaults['borg'], 144 'borg', defaults['borg'],
138 check_list_of_dicts) 145 check_list_of_dicts)
139 146
140 check_and_set(settings, 'backup_interval', 'top-level', defaults, check_nonneg_int) 147 check_and_set(settings, 'backup_interval', 'top-level', defaults, check_nonneg_int)
141 check_and_set(settings, 'retry_interval', 'top-level', defaults, check_nonneg_int) 148 check_and_set(settings, 'retry_interval', 'top-level', defaults, check_nonneg_int)
142 check_and_set(settings, '__extract_passphrases_at_startup', 'top-level', defaults, check_nonneg_int) 149 check_and_set(settings, 'extract_passphrases_at_startup', 'top-level', defaults, check_nonneg_int)
150 check_and_set(settings, 'no_quit_menu_entry', 'top-level', defaults, check_bool)
143 check_and_set(settings, 'borg', 'top-level', defaults, check_dict) 151 check_and_set(settings, 'borg', 'top-level', defaults, check_dict)
144 # Check parameters within 'borg' 152 # Check parameters within 'borg'
145 if True: 153 if True:
146 check_and_set(settings['borg'], 'executable', 'borg', 154 check_and_set(settings['borg'], 'executable', 'borg',
147 defaults['borg'], check_string) 155 defaults['borg'], check_string)

mercurial