Author: jkupec
Date: Mon Jul 30 14:26:52 2007
New Revision: 6284
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6284&view=rev
Log:
- output functions for progress reporting now take ostream as argument
- made some progress displayed by default. This will need more tuning.
Modified:
trunk/zypper/src/zypper-callbacks.cc
trunk/zypper/src/zypper-callbacks.h
trunk/zypper/src/zypper-media-callbacks.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-rpm-callbacks.h
trunk/zypper/src/zypper-source-callbacks.h
Modified: trunk/zypper/src/zypper-callbacks.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.cc?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.cc (original)
+++ trunk/zypper/src/zypper-callbacks.cc Mon Jul 30 14:26:52 2007
@@ -2,46 +2,46 @@
#include "zypper.h"
#include
-#include <iostream>
#include <sstream>
using namespace std;
-void display_progress (const string& s, int percent) {
+void display_progress (ostream & out, const string& s, int percent) {
static AliveCursor cursor;
if ( percent == 100 )
- cout_v << CLEARLN << cursor.done() << " " << s;
+ out << CLEARLN << cursor.done() << " " << s;
else
- cout_v << CLEARLN << cursor++ << " " << s;
+ out << CLEARLN << cursor++ << " " << s;
// dont display percents if invalid
if (percent >= 0 && percent <= 100)
- cout_v << " [" << percent << "%]";
- cout_v << flush;
+ out << " [" << percent << "%]";
+ out << flush;
}
// ----------------------------------------------------------------------------
-void display_tick (const string& s) {
+void display_tick (ostream & out, const string& s) {
static AliveCursor cursor;
cursor++;
- cout_v << CLEARLN << cursor << " " << s;
- cout_v << flush;
+ out << CLEARLN << cursor << " " << s;
+ out << flush;
}
// ----------------------------------------------------------------------------
-void display_done (const string& s) {
+void display_done (ostream & out, const string& s) {
static AliveCursor cursor;
- cout_v << CLEARLN << cursor.done() << " " << s;
- cout_v << flush;
+ out << CLEARLN << cursor.done() << " " << s;
+ out << flush;
+ out << endl;
}
// ----------------------------------------------------------------------------
-void display_done () {
- cout_v << endl;
+void display_done (ostream & out) {
+ out << endl;
}
// ----------------------------------------------------------------------------
Modified: trunk/zypper/src/zypper-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.h?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.h (original)
+++ trunk/zypper/src/zypper-callbacks.h Mon Jul 30 14:26:52 2007
@@ -10,7 +10,9 @@
#ifndef ZYPPER_CALLBACKS_H
#define ZYPPER_CALLBACKS_H
+#include <iostream>
#include <string>
+
#include
#include "zypper.h"
@@ -23,11 +25,11 @@
INVALID,
};
*/
-void display_progress (const std::string& s, int percent);
-void display_tick (const std::string& s);
-void display_done (const std::string& s);
+void display_progress (std::ostream & out, const std::string& s, int percent);
+void display_tick (std::ostream & out, const std::string& s);
+void display_done (ostream & out, const std::string& s);
// newline if normal progress is on single line
-void display_done ();
+void display_done (ostream & out);
template<typename Error>
void display_error (Error error, const std::string& reason) {
Modified: trunk/zypper/src/zypper-media-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-media-callbacks.h?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-media-callbacks.h (original)
+++ trunk/zypper/src/zypper-media-callbacks.h Mon Jul 30 14:26:52 2007
@@ -58,26 +58,26 @@
virtual void start( const zypp::Url & file, zypp::Pathname localfile )
{
cout_v << CLEARLN << _("Downloading: ") << file;
- cout_vv << " to " << localfile;
+ cout_vv << " to " << localfile;
cout_v << std::endl;
}
virtual bool progress(int value, const zypp::Url & /*file*/)
{
- display_progress ("Downloading", value);
+ display_progress (cout_v, "Downloading", value);
return true;
}
virtual DownloadProgressReport::Action problem( const zypp::Url & /*file*/, DownloadProgressReport::Error error, const std::string & description )
{
- display_done ();
+ display_done (cout_v);
display_error (error, description);
return DownloadProgressReport::ABORT;
}
virtual void finish( const zypp::Url & /*file*/, Error error, const std::string & konreason )
{
- display_done ();
+ display_done (cout_v);
display_error (error, konreason);
}
};
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Mon Jul 30 14:26:52 2007
@@ -502,7 +502,6 @@
cout_v << " " << format(_("(%d resolvables found)")) % store.size();
God->addResolvables(store);
- cout_n << endl;
}
catch (const Exception & e)
{
Modified: trunk/zypper/src/zypper-rpm-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-rpm-callbacks.h?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-rpm-callbacks.h (original)
+++ trunk/zypper/src/zypper-rpm-callbacks.h Mon Jul 30 14:26:52 2007
@@ -74,13 +74,13 @@
}
/** Report error. */
virtual void problem( const std::string & description ) {
- display_done ();
+ display_done (cout_n);
cerr << description << endl;
}
/** Report success. */
virtual void finish() {
- display_done ();
+ display_done (cout_n);
}
};
@@ -107,7 +107,7 @@
// this is called too often. relax a bit.
static int last = -1;
if (last != value)
- display_progress (_("Reading installed packages"), value);
+ display_progress (cout, _("Reading installed packages"), value);
last = value;
return true;
}
@@ -119,7 +119,7 @@
virtual void finish( Error error, const std::string & reason )
{
- display_done ();
+ display_done (cout);
display_error (error, reason);
}
};
@@ -137,7 +137,7 @@
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
{
// TranslatorExplanation This text is a progress display label e.g. "Removing [42%]"
- display_progress (_("Removing ") + to_string (resolvable), value);
+ display_progress (cout, _("Removing ") + to_string (resolvable), value);
return true;
}
@@ -150,7 +150,7 @@
virtual void finish( zypp::Resolvable::constPtr /*resolvable*/, Error error, const std::string & reason )
{
- display_done ();
+ display_done (cout);
display_error (error, reason);
}
};
@@ -172,7 +172,7 @@
void display_step( zypp::Resolvable::constPtr /*resolvable*/, int value )
{
// TranslatorExplanation This text is a progress display label e.g. "Installing [42%]"
- display_progress (_("Installing ") /* + to_string (resolvable) */, value);
+ display_progress (cout, _("Installing ") /* + to_string (resolvable) */, value);
}
virtual void start( zypp::Resolvable::constPtr resolvable )
@@ -210,7 +210,7 @@
virtual void finish( zypp::Resolvable::constPtr /*resolvable*/, Error error, const std::string & reason, RpmLevel level )
{
- display_done ();
+ display_done (cout);
if (error != NO_ERROR) {
cerr << level;
}
Modified: trunk/zypper/src/zypper-source-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-source-callbacks.h?rev=6284&r1=6283&r2=6284&view=diff
==============================================================================
--- trunk/zypper/src/zypper-source-callbacks.h (original)
+++ trunk/zypper/src/zypper-source-callbacks.h Mon Jul 30 14:26:52 2007
@@ -25,6 +25,7 @@
#include "zypper.h"
#include "zypper-callbacks.h"
+
///////////////////////////////////////////////////////////////////
namespace ZmartRecipients
{
@@ -80,7 +81,7 @@
void display_step( const std::string &what, int value )
{
- display_progress (what, value);
+ display_progress (cout_v, what, value);
}
// Dowmload delta rpm:
@@ -110,7 +111,7 @@
virtual void finishDeltaDownload()
{
- display_done ();
+ display_done (cout_v);
}
// Apply delta rpm:
@@ -136,7 +137,7 @@
virtual void finishDeltaApply()
{
- display_done ();
+ display_done (cout_v);
}
// Dowmload patch rpm:
@@ -165,7 +166,7 @@
virtual void finishPatchDownload()
{
- display_done ();
+ display_done (cout_v);
}
@@ -206,7 +207,7 @@
virtual void finish( zypp::Resolvable::constPtr /*resolvable_ptr*/, Error error, const std::string & reason )
{
- display_done ();
+ display_done (cout_v);
display_error (error, reason);
}
};
@@ -218,11 +219,11 @@
//std::cout << "TICK!" << std::endl;
if ( data.reportAlive() )
{
- display_tick ( data.name() );
+ display_tick (cout, data.name() );
}
else
{
- display_progress ( data.name() , data.val() );
+ display_progress (cout, data.name() , data.val() );
}
@@ -248,7 +249,7 @@
virtual void finish( const zypp::ProgressData &data )
{
- display_done( data.name() );
+ display_done(cout, data.name() );
}
};
@@ -262,12 +263,12 @@
display_step(0);
}
-
+
void display_step( int value )
{
- display_progress ("(" + _repo.info().alias() + ") " + _task , value);
+ display_progress (cout, "(" + _repo.info().alias() + ") " + _task , value);
}
-
+
virtual bool progress( int value )
{
display_step(value);
@@ -276,7 +277,7 @@
virtual Action problem( zypp::Repository /*repo*/, Error error, const std::string & description )
{
- display_done ();
+ display_done (cout);
display_error (error, description);
return (Action) read_action_ari (ABORT);
}
@@ -286,12 +287,12 @@
display_step(100);
// many of these, avoid newline
if (boost::algorithm::starts_with (task, "Reading patch"))
- cerr_v << '\r' << flush;
+ cout << '\r' << flush;
else
- display_done ();
+ display_done (cout);
display_error (error, reason);
}
-
+
std::string _task;
zypp::Repository _repo;
};
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org