From c722c3e16cb01b0d50db46793f4f624e8208acb4 Mon Sep 17 00:00:00 2001 From: owsla Date: Wed, 11 Jun 2008 19:36:20 +0000 Subject: flush stdout before running other commands, and add a --quiet option git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@890 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 4 ++++ rdiff-backup/rdiff-backup-statistics | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 4432452..cb60a5c 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,10 @@ New in v1.1.16 (????/??/??) --------------------------- +rdiff-backup-statistics enhancements suggested by James Marsh: flush stdout +before running other commands, and add a --quiet option to suppress printing +the "Processing statistics from session..." lines. (Andrew Ferguson) + Don't set modification times for directories on Windows. Also, assume that user has access to all files on Windows since there is no support for getuid(). (Patch from Josh Nisly) diff --git a/rdiff-backup/rdiff-backup-statistics b/rdiff-backup/rdiff-backup-statistics index 35d0fc1..9627e87 100755 --- a/rdiff-backup/rdiff-backup-statistics +++ b/rdiff-backup/rdiff-backup-statistics @@ -28,11 +28,12 @@ begin_time = None # Parse statistics at or after this time... end_time = None # ... and at or before this time (epoch seconds) min_ratio = .05 # report only files/directories over this number separator = "\n" # The line separator in file_statistics file +quiet = False # Suppress the "Processing statistics from session ..." lines def parse_args(): - global begin_time, end_time, min_ratio, separator + global begin_time, end_time, min_ratio, separator, quiet try: optlist, args = getopt.getopt(sys.argv[1:], "", - ["begin-time=", "end-time=", "minimum-ratio=", "null-separator"]) + ["begin-time=", "end-time=", "minimum-ratio=", "null-separator", "quiet"]) except getopt.error, e: sys.exit("Bad command line: " + str(e)) @@ -41,6 +42,7 @@ def parse_args(): elif opt == "--end-time": end_time = Time.genstrtotime(arg) elif opt == "--minimum-ratio": min_ratio = float(arg) elif opt == "--null-separator": separator = '\0' + elif opt == "--quiet": quiet = True else: assert 0 if len(args) != 1: @@ -56,6 +58,7 @@ def parse_args(): if len(sys.argv) == 3: tag = sys.argv[2] def system(cmd): + sys.stdout.flush() if os.system(cmd): sys.exit("Error running command '%s'\n" % (cmd,)) @@ -406,11 +409,12 @@ class ReadlineBuffer: def sum_fst(rp_pairs): """Add the file statistics given as list of (session_rp, file_rp) pairs""" + global quiet n = len(rp_pairs) - print "Processing statistics from session 1 of %d" % (n,) + if not quiet: print "Processing statistics from session 1 of %d" % (n,) total_fst = make_fst(*rp_pairs[0]) for i in range(1, n): - print "Processing statistics from session %d of %d" % (i+1, n) + if not quiet: print "Processing statistics from session %d of %d" % (i+1, n) session_rp, filestat_rp = rp_pairs[i] fst = make_fst(session_rp, filestat_rp) total_fst += fst -- cgit v1.2.1