git @ Cat's Eye Technologies ellsync / 6062800
Factor perform_sync() back into sync command code. Chris Pressey 2 years ago
1 changed file(s) with 11 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
1111 if not dirname.endswith('/'):
1212 dirname += '/'
1313 return dirname
14
15
16 def perform_sync(from_dir, to_dir, dry_run=True, checksum=False):
17 for d in (from_dir, to_dir):
18 if not os.path.isdir(d):
19 raise ValueError("Directory '{}' is not present".format(d))
20 dry_run_option = '--dry-run ' if dry_run else ''
21 checksum_option = '--checksum ' if checksum else ''
22 cmd = 'rsync {}{}--archive --verbose --delete "{}" "{}"'.format(dry_run_option, checksum_option, from_dir, to_dir)
23 run_command(cmd)
24 if not dry_run:
25 run_command('sync')
2614
2715
2816 def run_command(cmd):
6856 from_dir = clean_dir(from_dir)
6957 to_dir = clean_dir(to_dir)
7058
71 perform_sync(from_dir, to_dir, dry_run=(not options.apply), checksum=(options.thorough))
59 for d in (from_dir, to_dir):
60 if not os.path.isdir(d):
61 raise ValueError("Directory '{}' is not present".format(d))
62
63 dry_run = not options.apply
64 dry_run_option = '--dry-run ' if dry_run else ''
65 checksum_option = '--checksum ' if options.thorough else ''
66 cmd = 'rsync {}{}--archive --verbose --delete "{}" "{}"'.format(dry_run_option, checksum_option, from_dir, to_dir)
67 run_command(cmd)
68 if not dry_run:
69 run_command('sync')
7270
7371
7472 def rename(router, options):