- supress progress output when --quiet
authorJan Kupec <jkupec@suse.cz>
Tue, 30 Oct 2007 14:23:59 +0000 (14:23 +0000)
committerJan Kupec <jkupec@suse.cz>
Tue, 30 Oct 2007 14:23:59 +0000 (14:23 +0000)
src/zypper-media-callbacks.h
src/zypper-rpm-callbacks.h
src/zypper-source-callbacks.h

index 5f67b09..6abddc6 100644 (file)
@@ -73,7 +73,9 @@ namespace ZmartRecipients
   {
     virtual void start( const zypp::Url & file, zypp::Pathname localfile )
     {
-      if (gSettings.verbosity == VERBOSITY_MEDIUM || gData.show_media_progress_hack)
+      if (gSettings.verbosity < VERBOSITY_NORMAL)
+        return;
+      else if (gSettings.verbosity == VERBOSITY_MEDIUM || gData.show_media_progress_hack)
       {
         cout << CLEARLN << _("Downloading: ")
           << zypp::Pathname(file.getPathName()).basename()
@@ -87,6 +89,8 @@ namespace ZmartRecipients
 
     virtual bool progress(int value, const zypp::Url & /*file*/)
     {
+      if (gSettings.verbosity < VERBOSITY_NORMAL)
+        return true;
       if (gData.show_media_progress_hack)
         display_progress ("download", cout, "Downloading", value);
       else
@@ -97,10 +101,13 @@ namespace ZmartRecipients
     // not used anywhere in libzypp 3.20.0
     virtual DownloadProgressReport::Action problem( const zypp::Url & /*file*/, DownloadProgressReport::Error error, const std::string & description )
     {
-      if (gData.show_media_progress_hack)
-        display_done ("download", cout);
-      else
-        display_done ("download", cout_v);
+      if (gSettings.verbosity >= VERBOSITY_NORMAL)
+      {
+        if (gData.show_media_progress_hack)
+          display_done ("download", cout_n);
+        else
+          display_done ("download", cout_v);
+      }
       display_error (error, description);
       return DownloadProgressReport::ABORT;
     }
@@ -108,7 +115,9 @@ namespace ZmartRecipients
     // used only to finish, errors will be reported in media change callback (libzypp 3.20.0)
     virtual void finish( const zypp::Url & /*file*/, Error error, const std::string & konreason )
     {
-      if (gData.show_media_progress_hack)
+      if (gSettings.verbosity < VERBOSITY_NORMAL)
+        return;
+      else if (gData.show_media_progress_hack)
         display_done ("download", cout);
       else
         display_done ("download", cout_v);
index f534a71..723cb24 100644 (file)
@@ -114,7 +114,7 @@ struct ScanRpmDbReceive : public zypp::callback::ReceiveReport<zypp::target::rpm
     // this is called too often. relax a bit.
     static int last = -1;
     if (last != value)
-      display_progress ( "read-installed-packages", cout, _("Reading installed packages"), value);
+      display_progress ( "read-installed-packages", cout_n, _("Reading installed packages"), value);
     last = value;
     return true;
   }
@@ -126,7 +126,7 @@ struct ScanRpmDbReceive : public zypp::callback::ReceiveReport<zypp::target::rpm
 
   virtual void finish( Error error, const std::string & reason )
   {
-    display_done ("read-installed-packages", cout);
+    display_done ("read-installed-packages", cout_n);
     display_error (error, reason);
   }
 };
@@ -145,7 +145,7 @@ struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReport<zyp
   virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
   {
     // TranslatorExplanation This text is a progress display label e.g. "Removing [42%]"
-    display_progress ( "remove-resolvable", cout,
+    display_progress ( "remove-resolvable", cout_n,
         _("Removing ") + resolvable->name() + string("-") + resolvable->edition().asString(), value);
     return true;
   }
@@ -183,7 +183,7 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zy
     // TranslatorExplanation This text is a progress display label e.g. "Installing foo-1.1.2 [42%]"
     string s = boost::str(boost::format(_("Installing: %s-%s"))
         % resolvable->name() % resolvable->edition());
-    display_progress ( "install-resolvable", cout, s,  value);
+    display_progress ( "install-resolvable", cout_n, s,  value);
   }
 
   virtual void start( zypp::Resolvable::constPtr resolvable )
index b2a2a43..84075ec 100644 (file)
@@ -219,9 +219,9 @@ struct ProgressReportReceiver  : public zypp::callback::ReceiveReport<zypp::Prog
   void tick( const zypp::ProgressData &data )
   {
     if ( data.reportAlive() )
-      display_tick (zypp::str::numstring(data.numericId()), cout, data.name() );
+      display_tick (zypp::str::numstring(data.numericId()), cout_n, data.name() );
     else
-      display_progress ( zypp::str::numstring(data.numericId()), cout, data.name() , data.val() );
+      display_progress ( zypp::str::numstring(data.numericId()), cout_n, data.name() , data.val() );
   }
   
   virtual void start( const zypp::ProgressData &data )
@@ -244,7 +244,7 @@ struct ProgressReportReceiver  : public zypp::callback::ReceiveReport<zypp::Prog
 
   virtual void finish( const zypp::ProgressData &data )
   {
-    display_done(zypp::str::numstring(data.numericId()), cout, data.name() );
+    display_done(zypp::str::numstring(data.numericId()), cout_n, data.name() );
   }
 };
 
@@ -260,7 +260,7 @@ struct RepoReportReceiver  : public zypp::callback::ReceiveReport<zypp::repo::Re
 
   void display_step(const zypp::ProgressData & pd)
   {
-    display_progress("repo", cout, "(" + _repo.name() + ") " + pd.name(), pd.val());
+    display_progress("repo", cout_n, "(" + _repo.name() + ") " + pd.name(), pd.val());
   }
 
   virtual bool progress(const zypp::ProgressData & pd)
@@ -271,7 +271,7 @@ struct RepoReportReceiver  : public zypp::callback::ReceiveReport<zypp::repo::Re
   
   virtual Action problem( zypp::Repository /*repo*/, Error error, const std::string & description )
   {
-    display_done ("repo", cout);
+    display_done ("repo", cout_n);
     display_error (error, description);
     return (Action) read_action_ari (ABORT);
   }
@@ -281,9 +281,9 @@ struct RepoReportReceiver  : public zypp::callback::ReceiveReport<zypp::repo::Re
     display_step(100);
     // many of these, avoid newline
     if (boost::algorithm::starts_with (task, "Reading patch"))
-      cout << '\r' << flush;
+      cout_n << '\r' << flush;
     else
-      display_done ("repo", cout);
+      display_done ("repo", cout_n);
     display_error (error, reason);
   }