]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
Rework "bup fsck" output; allow less verbosity.
authorRob Browning <rlb@defaultvalue.org>
Sat, 27 Apr 2013 15:48:45 +0000 (10:48 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 6 May 2013 02:44:16 +0000 (21:44 -0500)
Only print debug messages when verbose > 1 (i.e. -vv).

Use log() to print error messages to stderr instead of stdout.

When verbose level is at least 1, print a single descriptive line to
stdout.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
cmd/fsck-cmd.py

index 8ba2771d8ee7c3a3976393f8e80eca2f335d41e8..4d44dc73cdbc864d020f47f556ffb702b30199df 100755 (executable)
@@ -7,7 +7,7 @@ par2_ok = 0
 nullf = open('/dev/null')
 
 def debug(s):
-    if opt.verbose:
+    if opt.verbose > 1:
         log(s)
 
 def run(argv):
@@ -87,34 +87,44 @@ def do_pack(base, last):
             if opt.repair:
                 rresult = par2_repair(base)
                 if rresult != 0:
-                    print '%s par2 repair: failed (%d)' % (last, rresult)
+                    action_result = 'failed'
+                    log('%s par2 repair: failed (%d)\n' % (last, rresult))
                     code = rresult
                 else:
-                    print '%s par2 repair: succeeded (0)' % last
+                    action_result = 'repaired'
+                    log('%s par2 repair: succeeded (0)\n' % last)
                     code = 100
             else:
-                print '%s par2 verify: failed (%d)' % (last, vresult)
+                action_result = 'failed'
+                log('%s par2 verify: failed (%d)\n' % (last, vresult))
                 code = vresult
         else:
-            print '%s ok' % last
+            action_result = 'ok'
     elif not opt.generate or (par2_ok and not par2_exists):
         gresult = git_verify(base)
         if gresult != 0:
-            print '%s git verify: failed (%d)' % (last, gresult)
+            action_result = 'failed'
+            log('%s git verify: failed (%d)\n' % (last, gresult))
             code = gresult
         else:
             if par2_ok and opt.generate:
                 presult = par2_generate(base)
                 if presult != 0:
-                    print '%s par2 create: failed (%d)' % (last, presult)
+                    action_result = 'failed'
+                    log('%s par2 create: failed (%d)\n' % (last, presult))
                     code = presult
                 else:
-                    print '%s ok' % last
+                    action_result = 'generated'
             else:
-                print '%s ok' % last
+                action_result = 'ok'
     else:
         assert(opt.generate and (not par2_ok or par2_exists))
-        debug('    skipped: par2 file already generated.\n')
+        if par2_ok:
+            action_result = 'exists'
+        else:
+            action_result = 'skipped'
+    if opt.verbose:
+        print last, action_result
     return code
 
 
@@ -203,6 +213,6 @@ while len(outstanding):
     if not opt.verbose:
         progress('fsck (%d/%d)\r' % (count, len(extra)))
 
-if not opt.verbose and istty2:
-    log('fsck done.           \n')
+if istty2:
+    debug('fsck done.           \n')
 sys.exit(code)