# HG changeset patch # User Tero Marttila # Date 1329383866 -7200 # Node ID a2bc5cc9de4d00f8001872a228f1dd23e7228296 # Parent de69e9ba8f2278bac27dbdd9d8e63b9e015a7283 0.2.1: slightly improved error handling diff -r de69e9ba8f22 -r a2bc5cc9de4d scripts/pvlbackup-rsync-snapshot --- a/scripts/pvlbackup-rsync-snapshot Thu Feb 16 10:53:13 2012 +0200 +++ b/scripts/pvlbackup-rsync-snapshot Thu Feb 16 11:17:46 2012 +0200 @@ -146,15 +146,17 @@ # subsections section_path = section_name.split(':') - # lookup dict + # lookup section dict from config lookup = config + # XXX: sections are not in order, so we can't rely on the parent section being created before we handle the sub-section for name in section_path : + # possibly create if name not in lookup : lookup[name] = {} - + lookup = lookup[name] - + # found dict for this section config_section = lookup @@ -377,7 +379,7 @@ if os.path.exists(temp_path) : raise Exception("Old temp snapshot dir remains, please clean up: {path}".format(path=temp_path)) - log.info("Perform main snapshot: %s", snapshot_path) + log.info("Perform main snapshot: %s -> %s", self.source, snapshot_path) # build rsync options opts = dict(self.rsync_options) @@ -639,7 +641,11 @@ if options.config : # load - config = parse_config(options.config, config) + try : + config = parse_config(options.config, config) + except ConfigError as e: + log.error("Configuration error: %s: %s", options.config, e) + return 2 # manual? if options.target : @@ -672,9 +678,19 @@ # store options.rsync_options[option] = value - # all targets? + # what targets? if not targets : + # default to all defined targets targets = list(config['targets']) + + else : + # given ones, but verify they exist + for target in targets : + if target not in config['targets'] : + log.error("Unknown target given: %s", target) + log.info("Defined targets: %s", ' '.join(config['targets'])) + + return 2 # targets for name in targets : @@ -688,6 +704,9 @@ # run target.run(options) + # ok + return 0 + def config_defaults () : return dict( # snapshots/ naming diff -r de69e9ba8f22 -r a2bc5cc9de4d setup.py --- a/setup.py Thu Feb 16 10:53:13 2012 +0200 +++ b/setup.py Thu Feb 16 11:17:46 2012 +0200 @@ -3,7 +3,7 @@ setup( name = 'pvl.backup', - version = '0.2', + version = '0.2.1', url = 'http://hg.qmsk.net/pvl-backup/', author = 'Tero Marttila',