Browse Source

Require a --yes argument before actually cleaning data

tags/nilmtools-1.1.3^0
Jim Paris 11 years ago
parent
commit
fd1b33401f
2 changed files with 7 additions and 5 deletions
  1. +1
    -1
      Makefile
  2. +6
    -4
      src/cleanup.py

+ 1
- 1
Makefile View File

@@ -12,7 +12,7 @@ test: test_cleanup

test_cleanup:
src/cleanup.py -e extras/cleanup.cfg
src/cleanup.py -D extras/cleanup.cfg
src/cleanup.py extras/cleanup.cfg

test_insert:
@make install >/dev/null


+ 6
- 4
src/cleanup.py View File

@@ -96,9 +96,9 @@ def main(argv = None):
parser.add_argument("-u", "--url", action="store",
default="http://localhost/nilmdb/",
help="NilmDB server URL (default: %(default)s)")
parser.add_argument("-D", "--dry-run", action="store_true",
parser.add_argument("-y", "--yes", action="store_true",
default = False,
help="Don't actually remove any data")
help="Actually remove the data (default: no)")
parser.add_argument("-e", "--estimate", action="store_true",
default = False,
help="Estimate how much disk space will be used")
@@ -238,14 +238,16 @@ def main(argv = None):
timestamp_to_seconds(total)))
continue
printf(" removing data before %s\n", timestamp_to_human(remove_before))
if not args.dry_run:
if args.yes:
client.stream_remove(path, None, remove_before)
for ap in streams[path].also_clean_paths:
printf(" also removing from %s\n", ap)
if not args.dry_run:
if args.yes:
client.stream_remove(ap, None, remove_before)

# All done
if not args.yes:
printf("Note: specify --yes to actually perform removals\n")
return

if __name__ == "__main__":


Loading…
Cancel
Save