[mirrorbrain-commits] r8180 - in /trunk: mb/mb.py tools/scanner.pl

From: <poeml_at_mirrorbrain.org>
Date: Tue, 19 Oct 2010 00:22:36 -0000
Author: poeml
Date: Tue Oct 19 02:22:35 2010
New Revision: 8180

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8180&view=rev
Log:
mb scan:
- The output of the scanner has been improved, by introducing a -q|--quiet
  option.
  Used once, it'll show only a summary line per scanned mirror.
  Used twice, it'll produce no output, except errors.

Modified:
    trunk/mb/mb.py
    trunk/tools/scanner.pl

Modified: trunk/mb/mb.py
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb.py?rev=8180&r1=8179&r2=8180&view=diff
==============================================================================
--- trunk/mb/mb.py (original)
+++ trunk/mb/mb.py Tue Oct 19 02:22:35 2010
_at_@ -750,6 +750,9 @@
 
     _at_cmdln.option('--sql-debug', action='store_true',
                   help='Show SQL statements for debugging purposes.')
+    _at_cmdln.option('-q', '--quiet', dest='quietness', action='count', default=0,
+                  help='Produce less output. '
+                       'Can be given multiple times.')
     _at_cmdln.option('-v', '--verbose', dest='verbosity', action='count', default=0,
                   help='Increase verbosity for debugging purposes. '
                        'Can be given multiple times.')
_at_@ -789,6 +792,8 @@
             cmd.append('-S')
         for i in range(opts.verbosity):
             cmd.append('-v')
+        for i in range(opts.quietness):
+            cmd.append('-q')
 
         if opts.enable:
             cmd.append('-e')
_at_@ -887,7 +892,8 @@
             print textwrap.fill(', '.join(mirrors_skipped),
                                 initial_indent='    ', subsequent_indent='  ')
 
-        print 'Completed in', mb.util.timer_elapsed()
+        if opts.quietness < 2:
+            print 'Completed in', mb.util.timer_elapsed()
 
 
 

Modified: trunk/tools/scanner.pl
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/tools/scanner.pl?rev=8180&r1=8179&r2=8180&view=diff
==============================================================================
--- trunk/tools/scanner.pl (original)
+++ trunk/tools/scanner.pl Tue Oct 19 02:22:35 2010
_at_@ -46,7 +46,7 @@
 use Time::HiRes qw(gettimeofday);
 use Encode;
 
-my $version = '0.41';
+my $version = '2.13.4';
 my $verbose = 1;
 my $sqlverbose = 0;
 
_at_@ -118,7 +118,7 @@
 	elsif ($arg =~ m{^(-I|--top-include)}) { push _at_top_include_list, shift; }
 	elsif ($arg =~ m{^--exclude$})         { push _at_exclude_list, shift; }
 	elsif ($arg =~ m{^--exclude-rsync$})   { push _at_exclude_list_rsync, shift; }
-	elsif ($arg =~ m{^-q})                 { $verbose = 0; }
+	elsif ($arg =~ m{^-q})                 { $verbose--; }
 	elsif ($arg =~ m{^-v})                 { $verbose++; }
 	elsif ($arg =~ m{^-S})                 { $sqlverbose++; }
 	elsif ($arg =~ m{^-a})                 { $all_servers++; }
_at_@ -232,6 +232,7 @@
   push _at_cmd, '-b', $brain_instance;
   push _at_cmd, '-q' unless $verbose;
   push _at_cmd, ('-v') x ($verbose - 1) if $verbose > 1;
+  push _at_cmd, ('-q') x (-($verbose - 1)) if $verbose < 0;
   foreach my $item(_at_top_include_list) {
     push _at_cmd, '-I', $item;
   }
_at_@ -267,7 +268,7 @@
 }
 
 for my $row (_at_scan_list) {
-  print localtime(time) . " $row->{identifier}: starting\n" if $verbose;
+  print localtime(time) . " $row->{identifier}: starting\n" if $verbose > 0;
 
   # already in a transaction? why??
   #if($do_transaction) {
_at_@ -295,9 +296,11 @@
   my $ary_ref = $dbh->selectall_arrayref($sql) or die $dbh->errstr();
   my $initial_file_count = defined($ary_ref->[0]) ? $ary_ref->[0][0] : 0;
   if(length $start_dir) {
-    print localtime(time) . " $row->{identifier}: files in '$start_dir' before scan: $initial_file_count\n";
+    print localtime(time) . " $row->{identifier}: files in '$start_dir' before scan: $initial_file_count\n"
+      if $verbose > 0;
   } else {
-    print localtime(time) . " $row->{identifier}: total files before scan: $initial_file_count\n";
+    print localtime(time) . " $row->{identifier}: total files before scan: $initial_file_count\n"
+      if $verbose > 0;
   }
 
   if($do_transaction) {
_at_@ -330,7 +333,7 @@
 
   print localtime(time) . " $row->{identifier}: scanned $file_count files (" 
          . int($fpm/60) . "/s) in " 
-         . int($duration) . "s\n" if $verbose;
+         . int($duration) . "s\n" if $verbose > 0;
 
   $start = time();
   print localtime(time) . " $row->{identifier}: purging old files\n" if $verbose > 1;
_at_@ -341,14 +344,15 @@
   print "$sql\n" if $sqlverbose;
   $ary_ref = $dbh->selectall_arrayref($sql) or die $dbh->errstr();
   my $purge_file_count = defined($ary_ref->[0]) ? $ary_ref->[0][0] : 0;
-  print localtime(time) . " $row->{identifier}: files to be purged: $purge_file_count\n";
+  print localtime(time) . " $row->{identifier}: files to be purged: $purge_file_count\n" if $verbose > 0;
 
 
   $sql = "SELECT COUNT(*) FROM filearr WHERE $row->{id} = ANY(mirrors);";
   print "$sql\n" if $sqlverbose;
   $ary_ref = $dbh->selectall_arrayref($sql) or die $dbh->errstr();
   $file_count = defined($ary_ref->[0]) ? $ary_ref->[0][0] : 0;
-  print localtime(time) . " $row->{identifier}: total files after scan: $file_count\n";
+  print localtime(time) . " $row->{identifier}: total files after scan: $file_count " . 
+        "(delta: " . ($file_count - $initial_file_count) . ")\n" if $verbose > -1;
 
 
   $duration = time() - $start;




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Tue Oct 19 2010 - 00:22:37 GMT

This archive was generated by hypermail 2.3.0 : Tue Oct 19 2010 - 00:32:09 GMT