Author: dmacvicar
Date: Thu Aug 2 18:30:35 2007
New Revision: 6406
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6406&view=rev
Log:
xml output in terse mode
Modified:
trunk/zypper/src/zypper-callbacks.cc
trunk/zypper/src/zypper-callbacks.h
trunk/zypper/src/zypper-media-callbacks.h
trunk/zypper/src/zypper-rpm-callbacks.h
trunk/zypper/src/zypper-source-callbacks.h
trunk/zypper/src/zypper.cc
Modified: trunk/zypper/src/zypper-callbacks.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.cc?rev=6406&r1=6405&r2=6406&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.cc (original)
+++ trunk/zypper/src/zypper-callbacks.cc Thu Aug 2 18:30:35 2007
@@ -6,11 +6,14 @@
using namespace std;
-void display_progress (ostream & out, const string& s, int percent) {
+void display_progress ( const std::string &id, ostream & out, const string& s, int percent) {
static AliveCursor cursor;
if (gSettings.machine_readable)
+ {
+ cout << "" << endl;
return;
+ }
if ( percent == 100 )
out << CLEARLN << cursor.done() << " " << s;
@@ -24,11 +27,14 @@
// ----------------------------------------------------------------------------
-void display_tick (ostream & out, const string& s) {
+void display_tick ( const std::string &id, ostream & out, const string& s) {
static AliveCursor cursor;
if (gSettings.machine_readable)
+ {
+ cout << "" << endl;
return;
+ }
cursor++;
out << CLEARLN << cursor << " " << s;
@@ -37,11 +43,14 @@
// ----------------------------------------------------------------------------
-void display_done (ostream & out, const string& s) {
+void display_done ( const std::string &id, ostream & out, const string& s) {
static AliveCursor cursor;
if (gSettings.machine_readable)
+ {
+ cout << "" << endl;
return;
+ }
out << CLEARLN << cursor.done() << " " << s;
out << flush;
@@ -50,10 +59,14 @@
// ----------------------------------------------------------------------------
-void display_done (ostream & out) {
+void display_done (const std::string &id, ostream & out) {
if (gSettings.machine_readable)
+ {
+ display_done( id, cout, "");
return;
+ }
+
out << endl;
}
Modified: trunk/zypper/src/zypper-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.h?rev=6406&r1=6405&r2=6406&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.h (original)
+++ trunk/zypper/src/zypper-callbacks.h Thu Aug 2 18:30:35 2007
@@ -25,15 +25,16 @@
INVALID,
};
*/
-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);
+void display_progress ( const std::string &id, std::ostream & out, const std::string& s, int percent);
+void display_tick ( const std::string &id, std::ostream & out, const std::string& s);
+void display_done ( const std::string &id, ostream & out, const std::string& s);
// newline if normal progress is on single line
-void display_done (ostream & out);
+void display_done ( const std::string &id, ostream & out);
template<typename Error>
void display_error (Error error, const std::string& reason) {
- if (error != 0 /*NO_ERROR*/) {
+ if (error != 0 /*NO_ERROR*/)
+ {
static const char * error_s[] = {
// TranslatorExplanation These are reasons for various failures.
"", _("Not found"), _("I/O error"), _("Invalid object")
Modified: trunk/zypper/src/zypper-media-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-media-callbacks.h?rev=6406&r1=6405&r2=6406&view=diff
==============================================================================
--- trunk/zypper/src/zypper-media-callbacks.h (original)
+++ trunk/zypper/src/zypper-media-callbacks.h Thu Aug 2 18:30:35 2007
@@ -64,20 +64,20 @@
virtual bool progress(int value, const zypp::Url & /*file*/)
{
- display_progress (cout_v, "Downloading", value);
+ display_progress ("download", cout_v, "Downloading", value);
return true;
}
virtual DownloadProgressReport::Action problem( const zypp::Url & /*file*/, DownloadProgressReport::Error error, const std::string & description )
{
- display_done (cout_v);
+ display_done ("download", cout_v);
display_error (error, description);
return DownloadProgressReport::ABORT;
}
virtual void finish( const zypp::Url & /*file*/, Error error, const std::string & konreason )
{
- display_done (cout_v);
+ display_done ("download", cout_v);
display_error (error, konreason);
}
};
Modified: trunk/zypper/src/zypper-rpm-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-rpm-callbacks.h?rev=6406&r1=6405&r2=6406&view=diff
==============================================================================
--- trunk/zypper/src/zypper-rpm-callbacks.h (original)
+++ trunk/zypper/src/zypper-rpm-callbacks.h Thu Aug 2 18:30:35 2007
@@ -35,8 +35,15 @@
{
virtual void show( zypp::Message::constPtr message )
{
- cout_v << message << endl; // [message]important-msg-1.0-1
- cout_n << message->text() << endl;
+ if ( !gSettings.machine_readable )
+ {
+ cout_v << message << endl; // [message]important-msg-1.0-1
+ cout_n << message->text() << endl;
+ return;
+ }
+
+ cout << "<message>" << message->text() << "</message>" << endl;
+
//! \todo in interactive mode, wait for ENTER?
}
};
@@ -74,13 +81,13 @@
}
/** Report error. */
virtual void problem( const std::string & description ) {
- display_done (cout_n);
+ display_done ( "run-script", cout_n);
cerr << description << endl;
}
/** Report success. */
virtual void finish() {
- display_done (cout_n);
+ display_done ("run-script", cout_n);
}
};
@@ -107,7 +114,7 @@
// this is called too often. relax a bit.
static int last = -1;
if (last != value)
- display_progress (cout, _("Reading installed packages"), value);
+ display_progress ( "read-installed-packages", cout, _("Reading installed packages"), value);
last = value;
return true;
}
@@ -119,7 +126,7 @@
virtual void finish( Error error, const std::string & reason )
{
- display_done (cout);
+ display_done ("read-installed-packages", cout);
display_error (error, reason);
}
};
@@ -130,14 +137,13 @@
{
virtual void start( zypp::Resolvable::constPtr resolvable )
{
- cout << boost::format(_("Removing: %s-%s"))
- % resolvable->name() % resolvable->edition() << endl;
+ display_progress ( "remove-resolvable", cout, _("Removing ") + to_string (resolvable), 0);
}
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
{
// TranslatorExplanation This text is a progress display label e.g. "Removing [42%]"
- display_progress (cout, _("Removing ") + to_string (resolvable), value);
+ display_progress ( "remove-resolvable", cout, _("Removing ") + to_string (resolvable), value);
return true;
}
@@ -150,7 +156,7 @@
virtual void finish( zypp::Resolvable::constPtr /*resolvable*/, Error error, const std::string & reason )
{
- display_done (cout);
+ display_done ( "remove-resolvable", cout);
display_error (error, reason);
}
};
@@ -169,20 +175,23 @@
{
zypp::Resolvable::constPtr _resolvable;
- void display_step( zypp::Resolvable::constPtr /*resolvable*/, int value )
+ void display_step( zypp::Resolvable::constPtr resolvable, int value )
{
// TranslatorExplanation This text is a progress display label e.g. "Installing [42%]"
- display_progress (cout, _("Installing ") /* + to_string (resolvable) */, value);
+ stringstream s;
+ s << (boost::format(_("Installing: %s-%s"))
+ % resolvable->name() % resolvable->edition());
+ display_progress ( "install-resolvable", cout, s.str(), value);
}
virtual void start( zypp::Resolvable::constPtr resolvable )
{
_resolvable = resolvable;
- if (gSettings.machine_readable)
- cout << "Installing: " + resolvable->name() << endl;
- else
- cout << boost::format(_("Installing: %s-%s"))
- % resolvable->name() % resolvable->edition() << endl;
+
+ stringstream s;
+ s << (boost::format(_("Installing: %s-%s"))
+ % resolvable->name() % resolvable->edition());
+ display_progress ( "install-resolvable", cout, s.str(), 0);
}
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
@@ -210,7 +219,7 @@
virtual void finish( zypp::Resolvable::constPtr /*resolvable*/, Error error, const std::string & reason, RpmLevel level )
{
- display_done (cout);
+ display_done ( "install-resolvable", 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=6406&r1=6405&r2=6406&view=diff
==============================================================================
--- trunk/zypper/src/zypper-source-callbacks.h (original)
+++ trunk/zypper/src/zypper-source-callbacks.h Thu Aug 2 18:30:35 2007
@@ -16,6 +16,7 @@
#include