Add --dry-run option to `deposit` utility.
Chris Pressey
6 years ago
51 | 51 | parser = OptionParser() |
52 | 52 | parser.add_option("--clean", default=False, action='store_true', |
53 | 53 | 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") | |
54 | 56 | |
55 | 57 | (options, args) = parser.parse_args() |
56 | 58 | |
72 | 74 | raise EnvironmentError("MD5 mismatch on '%s' - it might need to be renamed" % incoming_file) |
73 | 75 | print "*** %s exists, skipping" % canonical_file |
74 | 76 | else: |
77 | if options.dry_run: | |
78 | print "copying %s -> %s (DRY RUN)" % (incoming_file, canonical_file) | |
79 | continue | |
75 | 80 | print "copying %s -> %s" % (incoming_file, canonical_file) |
76 | 81 | mkdir_p(os.path.dirname(canonical_file)) |
77 | 82 | copy2(incoming_file, canonical_file) |
79 | 84 | |
80 | 85 | print "%s files copied" % num_copied |
81 | 86 | if options.clean: |
82 | if num_copied != 0: | |
87 | if options.dry_run or num_copied != 0: | |
83 | 88 | raise EnvironmentError("Can only clean on a non-copy pass (run script again to clean)") |
84 | 89 | for root, dirs, files in os.walk("."): |
85 | 90 | for filename in files: |