git @ Cat's Eye Technologies Space-Madness / master
Add --dry-run option to `deposit` utility. Chris Pressey 6 years ago
1 changed file(s) with 6 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5151 parser = OptionParser()
5252 parser.add_option("--clean", default=False, action='store_true',
5353 help="delete files once copied over")
54 parser.add_option("--dry-run", default=False, action='store_true',
55 help="don't actually modify the filesystem")
5456
5557 (options, args) = parser.parse_args()
5658
7274 raise EnvironmentError("MD5 mismatch on '%s' - it might need to be renamed" % incoming_file)
7375 print "*** %s exists, skipping" % canonical_file
7476 else:
77 if options.dry_run:
78 print "copying %s -> %s (DRY RUN)" % (incoming_file, canonical_file)
79 continue
7580 print "copying %s -> %s" % (incoming_file, canonical_file)
7681 mkdir_p(os.path.dirname(canonical_file))
7782 copy2(incoming_file, canonical_file)
7984
8085 print "%s files copied" % num_copied
8186 if options.clean:
82 if num_copied != 0:
87 if options.dry_run or num_copied != 0:
8388 raise EnvironmentError("Can only clean on a non-copy pass (run script again to clean)")
8489 for root, dirs, files in os.walk("."):
8590 for filename in files: