Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10536 - in /trunk/zypper/src/callbacks: keyring.h media.h repo.h rpm.h
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Fri, 11 Jul 2008 09:59:21 -0000
  • Message-id: <20080711095921.3119724B01@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Fri Jul 11 11:59:20 2008
New Revision: 10536

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10536&view=rev
Log:
- fixed too much progress output when installing/removing (bnc #404783)

Modified:
trunk/zypper/src/callbacks/keyring.h
trunk/zypper/src/callbacks/media.h
trunk/zypper/src/callbacks/repo.h
trunk/zypper/src/callbacks/rpm.h

Modified: trunk/zypper/src/callbacks/keyring.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/callbacks/keyring.h?rev=10536&r1=10535&r2=10536&view=diff
==============================================================================
--- trunk/zypper/src/callbacks/keyring.h (original)
+++ trunk/zypper/src/callbacks/keyring.h Fri Jul 11 11:59:20 2008
@@ -37,7 +37,7 @@
{
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 @@
{
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 @@
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 @@
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 @@
{
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),

Modified: trunk/zypper/src/callbacks/media.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/callbacks/media.h?rev=10536&r1=10535&r2=10536&view=diff
==============================================================================
--- trunk/zypper/src/callbacks/media.h (original)
+++ trunk/zypper/src/callbacks/media.h Fri Jul 11 11:59:20 2008
@@ -211,13 +211,13 @@

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 @@
public:
MediaCallbacks()
{
- MIL << "Set media callbacks.." << endl;
+ MIL << "Set media callbacks.." << std::endl;
_mediaChangeReport.connect();
_mediaDownloadReport.connect();
_mediaAuthenticationReport.connect();

Modified: trunk/zypper/src/callbacks/repo.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/callbacks/repo.h?rev=10536&r1=10535&r2=10536&view=diff
==============================================================================
--- trunk/zypper/src/callbacks/repo.h (original)
+++ trunk/zypper/src/callbacks/repo.h Fri Jul 11 11:59:20 2008
@@ -47,7 +47,7 @@
{
_delta = filename;
_delta_size = downloadsize;
- ostringstream s;
+ std::ostringstream s;
s << _("Downloading delta") << ": "
<< _delta << ", " << _delta_size;
Zypper::instance()->out().info(s.str());
@@ -56,7 +56,7 @@
virtual bool progressDeltaDownload( int value )
{
// seems this is never called, the progress is reported by the media
backend anyway
- INT << "not impelmented" << endl;
+ INT << "not impelmented" << std::endl;
// TranslatorExplanation This text is a progress display label e.g.
"Downloading delta [42%]"
//display_step( "apply-delta", ~("Downloading delta") /*+
_delta.asString()*/, value );
return true;
@@ -82,7 +82,7 @@
virtual void startDeltaApply( const zypp::Pathname & filename )
{
_delta = filename.basename();
- ostringstream s;
+ std::ostringstream s;
// translators: this text is a progress display label e.g. "Applying delta
foo [42%]"
s << _("Applying delta") << ": " << _delta;
_label_apply_delta = s.str();
@@ -113,7 +113,7 @@
{
_patch = filename.basename();
_patch_size = downloadsize;
- ostringstream s;
+ std::ostringstream s;
s << _("Downloading patch rpm") << ": " << _patch << ", " << _patch_size;
Zypper::instance()->out().info(s.str());
}
@@ -121,7 +121,7 @@
virtual bool progressPatchDownload( int value )
{
// seems this is never called, the progress is reported by the media
backend anyway
- INT << "not impelmented" << endl;
+ INT << "not impelmented" << std::endl;
// TranslatorExplanation This text is a progress display label e.g.
"Applying patch rpm [42%]"
//display_step( "apply-delta", _("Applying patch rpm") /* +
_patch.asString() */, value );
return true;
@@ -150,7 +150,7 @@
_url = url;
Zypper & zypper = *Zypper::instance();

- ostringstream s;
+ std::ostringstream s;
s << boost::format(_("Downloading %s %s-%s.%s"))
% kind_to_string_localized(_resolvable_ptr->kind(), 1)
% _resolvable_ptr->name()
@@ -175,7 +175,7 @@
virtual bool progress(int value, zypp::Resolvable::constPtr
/*resolvable_ptr*/)
{
// seems this is never called, the progress is reported by the media
backend anyway
- INT << "not impelmented" << endl;
+ INT << "not impelmented" << std::endl;
// TranslatorExplanation This text is a progress display label e.g.
"Downloading [42%]"
// display_step( "download-resolvable", ~("Downloading") /* +
resolvable_ptr->name() */, value );
return true;
@@ -184,7 +184,7 @@
virtual Action problem( zypp::Resolvable::constPtr resolvable_ptr, Error
/*error*/, const std::string & description )
{
Zypper::instance()->out().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)

Modified: trunk/zypper/src/callbacks/rpm.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/callbacks/rpm.h?rev=10536&r1=10535&r2=10536&view=diff
==============================================================================
--- trunk/zypper/src/callbacks/rpm.h (original)
+++ trunk/zypper/src/callbacks/rpm.h Fri Jul 11 11:59:20 2008
@@ -12,6 +12,7 @@

#include <iostream>
#include <sstream>
+#include <ctime>

#include <boost/format.hpp>

@@ -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 @@
virtual bool show( zypp::Patch::constPtr & patch )
{
Out & out = Zypper::instance()->out();
- 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 @@
_label = boost::str(
// TranslatorExplanation speaking of a script - "Running: script file
name (package name, script dir)"
boost::format(_("Running: %s (%s, %s)")) % path_r.basename() %
package->name() % path_r.dirname());
- cout << _label << endl;
+ std::cout << _label << std::endl;
}

/**
@@ -75,14 +89,14 @@
static bool was_ping_before = false;
if (kind == PING)
{
- cout << "." << flush;
+ std::cout << "." << std::flush;
was_ping_before = true;
}
else
{
if (was_ping_before)
- cout << endl;
- cout << output;
+ std::cout << std::endl;
+ std::cout << output;
was_ping_before = false;
}

@@ -162,9 +176,11 @@
struct RemoveResolvableReportReceiver : public
zypp::callback::ReceiveReport<zypp::target::rpm::RemoveResolvableReport>
{
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 @@

virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
{
+ // don't report too often
+ if (!report_again(&_last_reported))
+ return true;
+
Zypper::instance()->out().progress("remove-resolvable", _label, value);
return true;
}
@@ -180,7 +200,7 @@
virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error,
const std::string & description )
{
Zypper::instance()->out().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 @@
}
};

-ostream& operator << (ostream& stm,
zypp::target::rpm::InstallResolvableReport::RpmLevel level) {
+std::ostream & operator << (std::ostream & stm,
+
zypp::target::rpm::InstallResolvableReport::RpmLevel level)
+{
static const char * level_s[] = {
// TranslatorExplanation --nodeps and --force are options of the rpm
command, don't translate
//! \todo use format
@@ -212,13 +234,15 @@
{
zypp::Resolvable::constPtr _resolvable;
std::string _label;
-
+ timespec _last_reported;
+
void display_step( zypp::Resolvable::constPtr resolvable, int value )
{
}

virtual void start( zypp::Resolvable::constPtr resolvable )
{
+ clock_gettime(CLOCK_REALTIME, &_last_reported);
_resolvable = resolvable;
// TranslatorExplanation This text is a progress display label e.g.
"Installing foo-1.1.2 [42%]"
_label = boost::str(boost::format(_("Installing: %s-%s"))
@@ -228,6 +252,10 @@

virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
{
+ // don't report too often
+ if (!report_again(&_last_reported))
+ return true;
+
Zypper::instance()->out().progress("install-resolvable", _label, value);
return true;
}
@@ -242,7 +270,7 @@
}

Zypper::instance()->out().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 @@
if (error != NO_ERROR && level < RPM_NODEPS_FORCE)
{
DBG << "level < RPM_NODEPS_FORCE: aborting without displaying an error"
- << endl;
+ << std::endl;
return;
}


--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages