Author: mlandres Date: Fri Dec 12 13:17:46 2008 New Revision: 11929 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11929&view=rev Log: - Add Exception::asUserHistory: Returns a single (multiline) string composed of asUserString and historyAsString. And use it in reports. Modified: trunk/libzypp/zypp/base/Exception.cc trunk/libzypp/zypp/base/Exception.h trunk/libzypp/zypp/media/MediaAria2c.cc trunk/libzypp/zypp/media/MediaCurl.cc trunk/libzypp/zypp/repo/PackageProvider.cc trunk/libzypp/zypp/target/TargetCallbackReceiver.cc trunk/libzypp/zypp/target/rpm/RpmDb.cc Modified: trunk/libzypp/zypp/base/Exception.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Exception.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/base/Exception.cc (original) +++ trunk/libzypp/zypp/base/Exception.cc Fri Dec 12 13:17:46 2008 @@ -68,6 +68,20 @@ return _(str.str().c_str()); } + std::string Exception::asUserHistory() const + { + if ( historyEmpty() ) + return asUserString(); + + std::string ret( asUserString() ); + if ( ret.empty() ) + return historyAsString(); + + ret += '\n'; + ret += historyAsString(); + return ret; + } + void Exception::remember( const Exception & old_r ) { if ( &old_r != this ) // no self-remember Modified: trunk/libzypp/zypp/base/Exception.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Exception.h?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/base/Exception.h (original) +++ trunk/libzypp/zypp/base/Exception.h Fri Dec 12 13:17:46 2008 @@ -181,7 +181,9 @@ /** Error message provided by \ref dumpOn as string. */ std::string asString() const; - /** Translated error message as string suitable for the user. */ + /** Translated error message as string suitable for the user. + * \see \ref asUserStringHistory + */ std::string asUserString() const; public: @@ -227,6 +229,8 @@ */ std::string historyAsString() const; + /** A single (multiline) string composed of \ref asUserString and \ref historyAsString. */ + std::string asUserHistory() const; //@} protected: Modified: trunk/libzypp/zypp/media/MediaAria2c.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAria2c.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaAria2c.cc (original) +++ trunk/libzypp/zypp/media/MediaAria2c.cc Fri Dec 12 13:17:46 2008 @@ -48,9 +48,9 @@ using namespace std; using namespace zypp::base; -namespace zypp +namespace zypp { -namespace media +namespace media { Pathname MediaAria2c::_cookieFile = "/var/lib/YaST2/cookies"; @@ -70,7 +70,7 @@ }; ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout); - + std::string ariaResponse( aria.receiveLine()); string::size_type pos = ariaResponse.find('/', 0 ); if( pos != string::npos ) @@ -138,7 +138,7 @@ true ) // does_download { MIL << "MediaAria2c::MediaAria2c(" << url_r << ", " << attach_point_hint_r << ")" << endl; - + if( !attachPoint().empty()) { PathInfo ainfo(attachPoint()); @@ -169,7 +169,7 @@ void MediaAria2c::attachTo (bool next) { // clear last arguments - _args.clear(); + _args.clear(); if ( next ) ZYPP_THROW(MediaNotSupportedException(_url)); @@ -187,7 +187,7 @@ setAttachPoint( mountpoint, true); } - disconnectFrom(); + disconnectFrom(); // Build the aria command. _args.push_back(_aria2cPath.asString()); @@ -195,12 +195,12 @@ _args.push_back("--summary-interval=1"); _args.push_back("--follow-metalink=mem"); _args.push_back( "--check-integrity=true"); - + // add the anonymous id. _args.push_back(str::form("--header=%s", anonymousIdHeader() )); _args.push_back(str::form("--header=%s", distributionFlavorHeader() )); // TODO add debug option - + // Transfer timeout { _xfer_timeout = TRANSFER_TIMEOUT; @@ -231,11 +231,11 @@ DBG << "Anonymous FTP identification: '" << id << "'" << endl; _userpwd = "anonymous:" + id; } - } - else + } + else { if ( _url.getScheme() == "ftp" ) - { + { _args.push_back(str::form("--ftp-user=%s", _url.getUsername().c_str() )); } else if ( _url.getScheme() == "http" || @@ -243,11 +243,11 @@ { _args.push_back(str::form("--http-user=%s", _url.getUsername().c_str() )); } - + if ( _url.getPassword().size() ) { if ( _url.getScheme() == "ftp" ) - { + { _args.push_back(str::form("--ftp-passwd=%s", _url.getPassword().c_str() )); } else if ( _url.getScheme() == "http" || @@ -260,7 +260,7 @@ // note, aria2c does not support setting the auth type with // (basic, digest yet) - + /*---------------------------------------------------------------* CURLOPT_PROXY: host[:port] @@ -343,7 +343,7 @@ if ( ! _proxyuserpwd.empty() ) { _args.push_back(str::form("--http-proxy-user=%s", _proxyuserpwd.c_str() )); - + string proxypassword( _url.getQueryParam( "proxypassword" ) ); if ( ! proxypassword.empty() ) { _args.push_back(str::form("--http-proxy-passwd=%s", proxypassword.c_str() )); @@ -358,7 +358,7 @@ // FIXME: need a derived class to propelly compare url's MediaSourceRef media( new MediaSource(_url.getScheme(), _url.asString())); setMediaSource(media); - + } bool @@ -407,7 +407,7 @@ void MediaAria2c::getFile( const Pathname & filename ) const { // Use absolute file name to prevent access of files outside of the - // hierarchy below the attach point. + // hierarchy below the attach point. getFileCopy(filename, localPath(filename).absolutename()); } @@ -415,28 +415,28 @@ { callback::SendReport<DownloadProgressReport> report; - Url fileurl(getFileUrl(_url, filename)); + Url fileurl(getFileUrl(_url, filename)); bool retry = false; ExternalProgram::Arguments args = _args; args.push_back(str::form("--dir=%s", target.dirname().c_str())); args.push_back(fileurl.asString()); - + do { try - { - report->start(_url, target.asString() ); - - ExternalProgram aria(args, ExternalProgram::Stderr_To_Stdout); - int nLine = 0; + { + report->start(_url, target.asString() ); + + ExternalProgram aria(args, ExternalProgram::Stderr_To_Stdout); + int nLine = 0; //Process response for(std::string ariaResponse( aria.receiveLine()); - ariaResponse.length(); + ariaResponse.length(); ariaResponse = aria.receiveLine()) - { + { //cout << ariaResponse; if (!ariaResponse.substr(0,31).compare("Exception: Authorization failed") ) @@ -448,11 +448,11 @@ if (!ariaResponse.substr(0,29).compare("Exception: Resource not found") ) { ZYPP_THROW(MediaFileNotFoundException(_url, filename)); - } + } if (!ariaResponse.substr(0,9).compare("[#2 SIZE:")) { - - if (!nLine) + + if (!nLine) { size_t left_bound = ariaResponse.find('(',0) + 1; size_t count = ariaResponse.find('%',left_bound) - left_bound; @@ -460,19 +460,19 @@ //progressData.toMax(); report->progress ( std::atoi(ariaResponse.substr(left_bound, count).c_str()), _url, -1, -1 ); nLine = 1; - } + } else { nLine = 0; - } - } + } + } } aria.close(); - + report->finish( _url , zypp::media::DownloadProgressReport::NO_ERROR, ""); retry = false; } - + // retry with proper authentication data catch (MediaUnauthorizedException & ex_r) { @@ -480,7 +480,7 @@ retry = true; else { - report->finish(fileurl, zypp::media::DownloadProgressReport::ACCESS_DENIED, ex_r.asUserString()); + report->finish(fileurl, zypp::media::DownloadProgressReport::ACCESS_DENIED, ex_r.asUserHistory()); ZYPP_RETHROW(ex_r); } @@ -489,7 +489,7 @@ catch (MediaException & excpt_r) { // FIXME: error number fix - report->finish(fileurl, zypp::media::DownloadProgressReport::ERROR, excpt_r.asUserString()); + report->finish(fileurl, zypp::media::DownloadProgressReport::ERROR, excpt_r.asUserHistory()); ZYPP_RETHROW(excpt_r); } } @@ -530,7 +530,7 @@ bool MediaAria2c::doGetDoesFileExist( const Pathname & filename ) const { - + DBG << filename.asString() << endl; return true; } @@ -584,7 +584,7 @@ getDirectoryYast( retlist, dirname, dots ); } -std::string MediaAria2c::getAria2cVersion() +std::string MediaAria2c::getAria2cVersion() { const char* argv[] = { @@ -605,7 +605,7 @@ Pathname MediaAria2c::whereisAria2c() { Pathname aria2cPathr(ARIA_DEFAULT_BINARY); - + const char* argv[] = { "whereis", @@ -615,23 +615,23 @@ }; ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout); - + std::string ariaResponse( aria.receiveLine()); aria.close(); - + string::size_type pos = ariaResponse.find('/', 0 ); - if( pos != string::npos ) + if( pos != string::npos ) { aria2cPathr = ariaResponse; string::size_type pose = ariaResponse.find(' ', pos + 1 ); aria2cPathr = ariaResponse.substr( pos , pose - pos ); MIL << "We will use aria2c located here: " << ariaResponse.substr( pos , pose - pos) << endl; } - else + else { MIL << "We don't know were is ari2ac binary. We will use aria2c located here: " << aria2cPathr << endl; } - + return aria2cPathr; } Modified: trunk/libzypp/zypp/media/MediaCurl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCurl.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaCurl.cc (original) +++ trunk/libzypp/zypp/media/MediaCurl.cc Fri Dec 12 13:17:46 2008 @@ -846,7 +846,7 @@ retry = true; else { - report->finish(fileurl, zypp::media::DownloadProgressReport::ACCESS_DENIED, ex_r.asUserString()); + report->finish(fileurl, zypp::media::DownloadProgressReport::ACCESS_DENIED, ex_r.asUserHistory()); ZYPP_RETHROW(ex_r); } } @@ -854,7 +854,7 @@ catch (MediaException & excpt_r) { // FIXME: error number fix - report->finish(fileurl, zypp::media::DownloadProgressReport::ERROR, excpt_r.asUserString()); + report->finish(fileurl, zypp::media::DownloadProgressReport::ERROR, excpt_r.asUserHistory()); ZYPP_RETHROW(excpt_r); } } Modified: trunk/libzypp/zypp/repo/PackageProvider.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/PackageProvider.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/repo/PackageProvider.cc (original) +++ trunk/libzypp/zypp/repo/PackageProvider.cc Fri Dec 12 13:17:46 2008 @@ -122,7 +122,7 @@ // TranslatorExplanation %s = name of the package being processed. std::string detail_str( str::form(_("Failed to provide Package %s. Do you want to retry retrieval?"), package_str.c_str() ) ); - detail_str += str::form( "\n\n%s\n%s", excpt.asUserString().c_str(), excpt.historyAsString().c_str() ); + detail_str += str::form( "\n\n%s", excpt.asUserHistory().c_str() ); switch ( report()->problem( _package, repo::DownloadResolvableReport::IO, detail_str.c_str() ) ) { @@ -214,7 +214,7 @@ } catch ( const Exception & excpt ) { - report()->problemDeltaDownload( excpt.asUserString() ); + report()->problemDeltaDownload( excpt.asUserHistory() ); return ManagedFile(); } report()->finishDeltaDownload(); Modified: trunk/libzypp/zypp/target/TargetCallbackReceiver.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetCallbackReceiver.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetCallbackReceiver.cc (original) +++ trunk/libzypp/zypp/target/TargetCallbackReceiver.cc Fri Dec 12 13:17:46 2008 @@ -32,17 +32,17 @@ RpmInstallPackageReceiver::~RpmInstallPackageReceiver () { } - - void RpmInstallPackageReceiver::reportbegin() + + void RpmInstallPackageReceiver::reportbegin() { } - - void RpmInstallPackageReceiver::reportend() + + void RpmInstallPackageReceiver::reportend() { } /** Start the operation */ - void RpmInstallPackageReceiver::start( const Pathname & name ) + void RpmInstallPackageReceiver::start( const Pathname & name ) { _report->start( _resolvable ); _abort = false; @@ -57,26 +57,26 @@ _abort = ! _report->progress( percent, _resolvable ); return _abort; } - - rpm::RpmInstallReport::Action + + rpm::RpmInstallReport::Action RpmInstallPackageReceiver::problem( Exception & excpt_r ) { - rpm::InstallResolvableReport::Action user = + rpm::InstallResolvableReport::Action user = _report->problem( _resolvable , rpm::InstallResolvableReport::INVALID - , excpt_r.asUserString() + , excpt_r.asUserHistory() , _level ); - + switch (user) { - case rpm::InstallResolvableReport::RETRY: + case rpm::InstallResolvableReport::RETRY: return rpm::RpmInstallReport::RETRY; - case rpm::InstallResolvableReport::ABORT: + case rpm::InstallResolvableReport::ABORT: return rpm::RpmInstallReport::ABORT; - case rpm::InstallResolvableReport::IGNORE: + case rpm::InstallResolvableReport::IGNORE: return rpm::RpmInstallReport::IGNORE; } - + return rpm::RpmInstallReport::problem( excpt_r ); } @@ -91,7 +91,7 @@ { _report->finish( _resolvable, rpm::InstallResolvableReport::INVALID, std::string(), _level ); } - + void RpmInstallPackageReceiver::tryLevel( target::rpm::InstallResolvableReport::RpmLevel level_r ) { _level = level_r; @@ -112,17 +112,17 @@ RpmRemovePackageReceiver::~RpmRemovePackageReceiver () { } - - void RpmRemovePackageReceiver::reportbegin() + + void RpmRemovePackageReceiver::reportbegin() { } - - void RpmRemovePackageReceiver::reportend() + + void RpmRemovePackageReceiver::reportend() { } /** Start the operation */ - void RpmRemovePackageReceiver::start( const std::string & name ) + void RpmRemovePackageReceiver::start( const std::string & name ) { _report->start( _resolvable ); } @@ -136,25 +136,25 @@ _abort = ! _report->progress( percent, _resolvable ); return _abort; } - - rpm::RpmRemoveReport::Action + + rpm::RpmRemoveReport::Action RpmRemovePackageReceiver::problem( Exception & excpt_r ) { - rpm::RemoveResolvableReport::Action user = + rpm::RemoveResolvableReport::Action user = _report->problem( _resolvable , rpm::RemoveResolvableReport::INVALID - , excpt_r.asUserString() + , excpt_r.asUserHistory() ); - + switch (user) { - case rpm::RemoveResolvableReport::RETRY: + case rpm::RemoveResolvableReport::RETRY: return rpm::RpmRemoveReport::RETRY; - case rpm::RemoveResolvableReport::ABORT: + case rpm::RemoveResolvableReport::ABORT: return rpm::RpmRemoveReport::ABORT; - case rpm::RemoveResolvableReport::IGNORE: + case rpm::RemoveResolvableReport::IGNORE: return rpm::RpmRemoveReport::IGNORE; } - + return rpm::RpmRemoveReport::problem( excpt_r ); } Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=11929&r1=11928&r2=11929&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Fri Dec 12 13:17:46 2008 @@ -828,7 +828,7 @@ } catch (RpmException & excpt_r) { - report->finish(root() + dbPath(), RebuildDBReport::FAILED, excpt_r.asUserString()); + report->finish(root() + dbPath(), RebuildDBReport::FAILED, excpt_r.asUserHistory()); ZYPP_RETHROW(excpt_r); } report->finish(root() + dbPath(), RebuildDBReport::NO_ERROR, ""); @@ -1238,7 +1238,7 @@ } catch (RpmException & excpt_r) { - report->finish(ScanDBReport::FAILED, excpt_r.asUserString ()); + report->finish(ScanDBReport::FAILED, excpt_r.asUserHistory ()); ZYPP_RETHROW(excpt_r); } #warning fixme -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org