]> git.cworth.org Git - sup/commitdiff
move sup-sync output from stderr to stdout
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 10 Sep 2009 14:22:37 +0000 (10:22 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Thu, 10 Sep 2009 14:25:43 +0000 (10:25 -0400)
bin/sup-sync

index ddcf8c567563574be9ecd3a1b84abf1daf51e024..5e89dac9cd8c479555a5f0b486a350a90bd438fd 100755 (executable)
@@ -99,13 +99,13 @@ index = Redwood::Index.init
 
 restored_state = if opts[:restore]
   dump = {}
-  $stderr.puts "Loading state dump from #{opts[:restore]}..."
+  puts "Loading state dump from #{opts[:restore]}..."
   IO.foreach opts[:restore] do |l|
     l =~ /^(\S+) \((.*?)\)$/ or raise "Can't read dump line: #{l.inspect}"
     mid, labels = $1, $2
     dump[mid] = labels.to_set_of_symbols
   end
-  $stderr.puts "Read #{dump.size} entries from dump file."
+  puts "Read #{dump.size} entries from dump file."
   dump
 else
   {}
@@ -139,7 +139,7 @@ begin
   end
 
   sources.each do |source|
-    $stderr.puts "Scanning #{source}..."
+    puts "Scanning #{source}..."
     num_added = num_updated = num_scanned = num_restored = 0
     last_info_time = start_time = Time.now
 
@@ -207,15 +207,15 @@ begin
       ## now, actually do the operation
       case dothis
       when :add_message
-        $stderr.puts "Adding new message #{source}###{m.source_info} with labels #{m.labels}" if opts[:verbose]
+        puts "Adding new message #{source}##{m.source_info} with labels #{m.labels}" if opts[:verbose]
         index.add_message m unless opts[:dry_run]
         num_added += 1
       when :update_message
-        $stderr.puts "Updating message #{source}###{m.source_info}; labels #{old_m.labels} => #{m.labels}; offset #{old_m.source_info} => #{m.source_info}" if opts[:verbose]
+        puts "Updating message #{source}##{m.source_info}; labels #{old_m.labels} => #{m.labels}; offset #{old_m.source_info} => #{m.source_info}" if opts[:verbose]
         index.update_message m unless opts[:dry_run]
         num_updated += 1
       when :update_message_state
-        $stderr.puts "Changing flags for #{source}##{m.source_info} from #{m.labels} to #{new_labels}"
+        puts "Changing flags for #{source}##{m.source_info} from #{m.labels} to #{new_labels}" if opts[:verbose]
         m.labels = new_labels
         index.update_message_state m unless opts[:dry_run]
         num_updated += 1
@@ -226,18 +226,18 @@ begin
         elapsed = last_info_time - start_time
         pctdone = source.respond_to?(:pct_done) ? source.pct_done : 100.0 * (source.cur_offset.to_f - source.start_offset).to_f / (source.end_offset - source.start_offset).to_f
         remaining = (100.0 - pctdone) * (elapsed.to_f / pctdone)
-        $stderr.printf "## read %dm (about %.0f%%) @ %.1fm/s. %s elapsed, about %s remaining\n", num_scanned, pctdone, num_scanned / elapsed, elapsed.to_time_s, remaining.to_time_s
+        printf "## read %dm (about %.0f%%) @ %.1fm/s. %s elapsed, about %s remaining\n", num_scanned, pctdone, num_scanned / elapsed, elapsed.to_time_s, remaining.to_time_s
       end
     end
 
-    $stderr.puts "Scanned #{num_scanned}, added #{num_added}, updated #{num_updated} messages from #{source}."
-    $stderr.puts "Restored state on #{num_restored} (#{100.0 * num_restored / num_scanned}%) messages." if num_restored > 0
+    puts "Scanned #{num_scanned}, added #{num_added}, updated #{num_updated} messages from #{source}."
+    puts "Restored state on #{num_restored} (#{100.0 * num_restored / num_scanned}%) messages." if num_restored > 0
   end
 
   ## delete any messages in the index that claim they're from one of
   ## these sources, but that we didn't see.
   if (target == :all || target == :changed)
-    $stderr.puts "Deleting missing messages from the index..."
+    puts "Deleting missing messages from the index..."
     num_del, num_scanned = 0, 0
     sources.each do |source|
       raise "no source id for #{source}" unless source.id
@@ -251,15 +251,15 @@ begin
         end
       end
     end
-    $stderr.puts "Deleted #{num_del} / #{num_scanned} messages"
+    puts "Deleted #{num_del} / #{num_scanned} messages"
   end
 
   index.save
 
   if opts[:optimize]
-    $stderr.puts "Optimizing index..."
+    puts "Optimizing index..."
     optt = time { index.optimize unless opts[:dry_run] }
-    $stderr.puts "Optimized index of size #{index.size} in #{optt}s."
+    puts "Optimized index of size #{index.size} in #{optt}s."
   end
 rescue Redwood::FatalSourceError => e
   $stderr.puts "Sorry, I couldn't communicate with a source: #{e.message}"