Bugzilla – Attachment 199664 Details for
Bug 168935
Yast package manager should show download rate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
zypper patch for trunk revision 9063
zypper-drate.diff (text/plain), 7.51 KB, created by
Jan Kupec
on 2008-03-09 01:11:26 UTC
(
hide
)
Description:
zypper patch for trunk revision 9063
Filename:
MIME Type:
Creator:
Jan Kupec
Created:
2008-03-09 01:11:26 UTC
Size:
7.51 KB
patch
obsolete
>Index: src/output/OutNormal.cc >=================================================================== >--- src/output/OutNormal.cc (revision 9063) >+++ src/output/OutNormal.cc (working copy) >@@ -2,6 +2,7 @@ > #include <sstream> > > #include "zypp/Pathname.h" >+#include "zypp/ByteCount.h" // for download progress reporting > > #include "../zypper-main.h" > #include "../AliveCursor.h" >@@ -150,7 +151,7 @@ > > void OutNormal::dwnldProgress(const zypp::Url & uri, > int value, >- int rate) >+ long rate) > { > if (verbosity() < NORMAL) > return; >@@ -162,12 +163,20 @@ > else > cout << zypp::Pathname(uri.getPathName()).basename(); > // dont display percents if invalid >- if (value >= 0 && value <= 100) >- cout << " [" << value << "%]"; >+ if ((value >= 0 && value <= 100) || rate >= 0) >+ { >+ cout << " ["; >+ if (value >= 0 && value <= 100) >+ cout << value << "%"; >+ if (rate >= 0) >+ cout << " (" << zypp::ByteCount(rate) << "/s)"; >+ cout << "]"; >+ } >+ > cout << std::flush; > } > >-void OutNormal::dwnldProgressEnd(const zypp::Url & uri, int rate, bool error) >+void OutNormal::dwnldProgressEnd(const zypp::Url & uri, long rate, bool error) > { > if (verbosity() < NORMAL) > return; >@@ -178,7 +187,10 @@ > cout << uri; //! \todo shorten to fit the width of the terminal > else > cout << zypp::Pathname(uri.getPathName()).basename(); >- cout << " [" << (error ? _("error") : _("done")) << "]"; >+ cout << " [" << (error ? _("error") : _("done")); >+ if (rate >= 0) >+ cout << " (" << zypp::ByteCount(rate) << "/s)"; >+ cout << "]"; > cout << endl << std::flush; > } > >Index: src/output/OutNormal.h >=================================================================== >--- src/output/OutNormal.h (revision 9063) >+++ src/output/OutNormal.h (working copy) >@@ -48,9 +48,9 @@ > virtual void dwnldProgressStart(const zypp::Url & uri); > virtual void dwnldProgress(const zypp::Url & uri, > int value = -1, >- int rate = -1); >+ long rate = -1); > virtual void dwnldProgressEnd(const zypp::Url & uri, >- int rate = -1, >+ long rate = -1, > bool error = false); > > virtual void prompt(PromptId id, >Index: src/output/OutXML.cc >=================================================================== >--- src/output/OutXML.cc (revision 9063) >+++ src/output/OutXML.cc (working copy) >@@ -168,7 +168,7 @@ > > void OutXML::dwnldProgress(const zypp::Url & uri, > int value, >- int rate) >+ long rate) > { > cout << "<download" > << " url=\"" << xml_encode(uri.asString()) << "\"" >@@ -177,7 +177,7 @@ > << "/>" << endl; > } > >-void OutXML::dwnldProgressEnd(const zypp::Url & uri, int rate, bool error) >+void OutXML::dwnldProgressEnd(const zypp::Url & uri, long rate, bool error) > { > cout << "<download" > << " url=\"" << xml_encode(uri.asString()) << "\"" >Index: src/output/Out.h >=================================================================== >--- src/output/Out.h (revision 9063) >+++ src/output/Out.h (working copy) >@@ -190,20 +190,20 @@ > * > * \param uri Uri of the file being downloaded. > * \param value Value of the progress in percents. -1 if unknown. >- * \param rate Download rate. -1 if unknown. >+ * \param rate Current download rate in B/s. -1 if unknown. > */ > virtual void dwnldProgress(const zypp::Url & uri, > int value = -1, >- int rate = -1) = 0; >+ long rate = -1) = 0; > /** > * Reports end of a download. > * > * \param uri Uri of the file to download. >- * \param rate Final download rate. -1 if unknown. >+ * \param rate Average download rate at the end. -1 if unknown. > * \param error Error flag - did the download finish with error? > */ > virtual void dwnldProgressEnd(const zypp::Url & uri, >- int rate = -1, >+ long rate = -1, > bool error = false) = 0; > //@} > >Index: src/output/OutXML.h >=================================================================== >--- src/output/OutXML.h (revision 9063) >+++ src/output/OutXML.h (working copy) >@@ -32,9 +32,9 @@ > virtual void dwnldProgressStart(const zypp::Url & uri); > virtual void dwnldProgress(const zypp::Url & uri, > int value = -1, >- int rate = -1); >+ long rate = -1); > virtual void dwnldProgressEnd(const zypp::Url & uri, >- int rate = -1, >+ long rate = -1, > bool error = false); > > virtual void prompt(PromptId id, >Index: src/zypper-media-callbacks.h >=================================================================== >--- src/zypper-media-callbacks.h (revision 9063) >+++ src/zypper-media-callbacks.h (working copy) >@@ -11,11 +11,10 @@ > #define ZMART_MEDIA_CALLBACKS_H > > #include <stdlib.h> >-#include <iostream> >+#include <ctime> > > #include <boost/format.hpp> > >-#include "zypp/base/Logger.h" > #include "zypp/ZYppCallbacks.h" > #include "zypp/Pathname.h" > #include "zypp/KeyRing.h" >@@ -69,7 +68,8 @@ > }; > > // progress for downloading a file >- struct DownloadProgressReportReceiver : public zypp::callback::ReceiveReport<zypp::media::DownloadProgressReport> >+ struct DownloadProgressReportReceiver >+ : public zypp::callback::ReceiveReport<zypp::media::DownloadProgressReport> > { > DownloadProgressReportReceiver() > : _gopts(Zypper::instance()->globalOpts()), _be_quiet(false) >@@ -77,6 +77,9 @@ > > virtual void start( const zypp::Url & uri, zypp::Pathname localfile ) > { >+ _last_reported = time(NULL); >+ _last_drate_avg = -1; >+ > Out & out = Zypper::instance()->out(); > > if (out.verbosity() < Out::HIGH && >@@ -98,12 +101,22 @@ > } > > //! \todo return false on SIGINT >- virtual bool progress(int value, const zypp::Url & uri) >+ virtual bool progress(int value, const zypp::Url & uri, double drate_avg, double drate_now) > { > if (_be_quiet) > return true; > >- Zypper::instance()->out().dwnldProgress(uri, value); //! \todo add transfer rate >+// std::cout << "avg: " << drate_avg << " current: " << drate_now << std::endl; >+ >+ // don't report more often than 1 second >+ time_t now = time(NULL); >+ if (now > _last_reported) >+ _last_reported = now; >+ else >+ return true; >+ >+ Zypper::instance()->out().dwnldProgress(uri, value, (long) drate_now); >+ _last_drate_avg = drate_avg; > return true; > } > >@@ -112,7 +125,7 @@ > problem( const zypp::Url & uri, DownloadProgressReport::Error error, const std::string & description ) > { > if (_be_quiet) >- Zypper::instance()->out().dwnldProgressEnd(uri, true); >+ Zypper::instance()->out().dwnldProgressEnd(uri, _last_drate_avg, true); > Zypper::instance()->out().error(zcb_error2str(error, description)); > > return (Action) read_action_ari(PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT); >@@ -124,12 +137,14 @@ > if (_be_quiet) > return; > >- Zypper::instance()->out().dwnldProgressEnd(uri); >+ Zypper::instance()->out().dwnldProgressEnd(uri, _last_drate_avg); > } > > private: > const GlobalOptions & _gopts; > bool _be_quiet; >+ time_t _last_reported; >+ double _last_drate_avg; > }; > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 168935
:
94423
|
118862
|
199663
| 199664