From: Jan Kupec Date: Fri, 11 Jul 2008 09:59:20 +0000 (+0000) Subject: - fixed too much progress output when installing/removing (bnc #404783) X-Git-Tag: BASE-SuSE-Code-11-Branch~214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de853ddfcf322b986add04b35bad0a0144e47251;p=platform%2Fupstream%2Fzypper.git - fixed too much progress output when installing/removing (bnc #404783) --- diff --git a/src/callbacks/keyring.h b/src/callbacks/keyring.h index 621b264..a89935f 100644 --- a/src/callbacks/keyring.h +++ b/src/callbacks/keyring.h @@ -37,7 +37,7 @@ namespace zypp { { if (_gopts.no_gpg_checks) { - MIL << "Accepting unsigned file (" << file << ")" << endl; + MIL << "Accepting unsigned file (" << file << ")" << std::endl; Zypper::instance()->out().warning(boost::str( boost::format(_("Accepting an unsigned file %s.")) % file), Out::HIGH); @@ -65,7 +65,7 @@ namespace zypp { { if (_gopts.no_gpg_checks) { - MIL << "Accepting file signed with an unknown key (" << file << "," << id << ")" << endl; + MIL << "Accepting file signed with an unknown key (" << file << "," << id << ")" << std::endl; Zypper::instance()->out().warning(boost::str(boost::format( _("Accepting file %s signed with an unknown key %s.")) % file % id)); @@ -86,7 +86,7 @@ namespace zypp { if (_gopts.no_gpg_checks) { MIL << boost::format("Automatically trusting key id %s, %s, fingerprint %s") - % keyid % keyname % fingerprint << endl; + % keyid % keyname % fingerprint << std::endl; Zypper::instance()->out().info(boost::str(boost::format( _("Automatically trusting key id %s, %s, fingerprint %s")) % keyid % keyname % fingerprint)); @@ -109,7 +109,7 @@ namespace zypp { MIL << boost::format( "Ignoring failed signature verification for %s" " with public key id %s, %s, fingerprint %s") - % file % keyid % keyname % fingerprint << endl; + % file % keyid % keyname % fingerprint << std::endl; Zypper::instance()->out().warning(boost::str(boost::format( _("Ignoring failed signature verification for %s" " with public key id %s, %s, fingerprint %s!\n" @@ -158,7 +158,7 @@ namespace zypp { { WAR << boost::format( "Ignoring failed digest verification for %s (expected %s, found %s).") - % file % requested % found << endl; + % file % requested % found << std::endl; Zypper::instance()->out().warning(boost::str(boost::format( _("Ignoring failed digest verification for %s (expected %s, found %s).")) % file % requested % found), diff --git a/src/callbacks/media.h b/src/callbacks/media.h index cf6abb2..ac3eea8 100644 --- a/src/callbacks/media.h +++ b/src/callbacks/media.h @@ -211,13 +211,13 @@ namespace ZmartRecipients Zypper::instance()->out().prompt( PROMPT_AUTH_USERNAME, description, PromptOptions(_("User Name"), 0)); - string username; + std::string username; std::cin >> username; auth_data_ptr->setUserName(username); Zypper::instance()->out().prompt( PROMPT_AUTH_PASSWORD, description, PromptOptions(_("Password"), 0)); - string password; + std::string password; std::cin >> password; if (password.empty()) return false; auth_data_ptr->setPassword(password); @@ -244,7 +244,7 @@ class MediaCallbacks { public: MediaCallbacks() { - MIL << "Set media callbacks.." << endl; + MIL << "Set media callbacks.." << std::endl; _mediaChangeReport.connect(); _mediaDownloadReport.connect(); _mediaAuthenticationReport.connect(); diff --git a/src/callbacks/repo.h b/src/callbacks/repo.h index 62a4cad..0db3173 100644 --- a/src/callbacks/repo.h +++ b/src/callbacks/repo.h @@ -47,7 +47,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReportout().info(s.str()); @@ -56,7 +56,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReportout().info(s.str()); } @@ -121,7 +121,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReportkind(), 1) % _resolvable_ptr->name() @@ -175,7 +175,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReportname() */, value ); return true; @@ -184,7 +184,7 @@ struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReportout().error(description); - DBG << "error report" << endl; + DBG << "error report" << std::endl; Action action = (Action) read_action_ari(PROMPT_ARI_RPM_DOWNLOAD_PROBLEM, ABORT); if (action == DownloadResolvableReport::RETRY) diff --git a/src/callbacks/rpm.h b/src/callbacks/rpm.h index 3e7468c..9a3f6cb 100644 --- a/src/callbacks/rpm.h +++ b/src/callbacks/rpm.h @@ -12,6 +12,7 @@ #include #include +#include #include @@ -19,12 +20,25 @@ #include "zypp/ZYppCallbacks.h" #include "zypp/Package.h" #include "zypp/Patch.h" -//#include "zypp/target/rpm/RpmCallbacks.h" #include "../Zypper.h" #include "../prompt.h" -using namespace std; + +static bool report_again(timespec * last) +{ + // don't report more often than 5 times per sec + timespec now; + clock_gettime(CLOCK_REALTIME, &now); + if (now.tv_sec > last->tv_sec || + (now.tv_sec == last->tv_sec && now.tv_nsec > last->tv_nsec + 200000000L)) + { + *last = now; + return true; + } + else + return false; +} /////////////////////////////////////////////////////////////////// namespace ZmartRecipients @@ -41,7 +55,7 @@ struct PatchMessageReportReceiver : public zypp::callback::ReceiveReportout(); - ostringstream s; + std::ostringstream s; s << patch; // [patch]important-patch-101 \todo make some meaningfull message out of this out.info(s.str(), Out::HIGH); out.info(patch->message()); @@ -61,7 +75,7 @@ struct PatchScriptReportReceiver : public zypp::callback::ReceiveReportname() % path_r.dirname()); - cout << _label << endl; + std::cout << _label << std::endl; } /** @@ -75,14 +89,14 @@ struct PatchScriptReportReceiver : public zypp::callback::ReceiveReport { std::string _label; + timespec _last_reported; virtual void start( zypp::Resolvable::constPtr resolvable ) { + ::clock_gettime(CLOCK_REALTIME, &_last_reported); // translators: This text is a progress display label e.g. "Removing packagename-x.x.x [42%]" _label = boost::str(boost::format(_("Removing %s-%s")) % resolvable->name() % resolvable->edition()); @@ -173,6 +189,10 @@ struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReportout().progress("remove-resolvable", _label, value); return true; } @@ -180,7 +200,7 @@ struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReportout().progressEnd("remove-resolvable", _label, true); - ostringstream s; + std::ostringstream s; s << boost::format(_("Removal of %s failed:")) % resolvable << std::endl; s << zcb_error2str(error, description); Zypper::instance()->out().error(s.str()); @@ -197,7 +217,9 @@ struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReportout().progress("install-resolvable", _label, value); return true; } @@ -242,7 +270,7 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReportout().progressEnd("install-resolvable", _label, true); - ostringstream s; + std::ostringstream s; s << boost::format(_("Installation of %s-%s failed:")) % resolvable->name() % resolvable->edition() << std::endl; s << level << " " << zcb_error2str(error, description); Zypper::instance()->out().error(s.str()); @@ -255,7 +283,7 @@ struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport