Changed console readout, making it more compact

"SIZE:" is removed because it is obvious. SEEDING, SEED, SPD and UP
are now replaced with SEED, SD, DL and UL respectively.
pull/36/head
Tatsuhiro Tsujikawa 2012-12-12 23:22:04 +09:00
parent 4fdd5da27d
commit 2235743de3
3 changed files with 66 additions and 108 deletions

View File

@ -3548,38 +3548,40 @@ Console Readout
While downloading files, aria2 prints the console readout to tell the While downloading files, aria2 prints the console readout to tell the
progress of the downloads. The console readout is like this:: progress of the downloads. The console readout is like this::
[#1 SIZE:400.0KiB/33.2MiB(1%) CN:1 SPD:115.7KiBs ETA:4m51s] [#1 400.0KiB/33.2MiB(1%) CN:1 DL:115.7KiB ETA:4m51s]
This section describes what these numbers and strings mean. This section describes what these numbers and strings mean.
``#N`` ``#N``
N means GID, which is an unique ID for each download. N means GID, which is an unique ID for each download.
``SIZE`` ``X/Y(Z%)``
Completed length and Total length in bytes. If Completed length, the total file length and its ratio. If
:option:`--select-file` is used, this is the sum of selected file. :option:`--select-file` is used, this is the sum of selected file.
``SEEDING`` ``SEED``
Share ratio. The client is now seeding. After BitTorrent download Share ratio. The client is now seeding. After BitTorrent download
finished, ``SIZE`` is replaced with ``SEEDING``. finished, size information is replaced with this.
``CN`` ``CN``
The number of connections the client has established. The number of connections the client has established.
``SEED`` ``SD``
The number of seeders the client has connected to. The number of seeders the client is now connecting to.
``SPD`` ``DL``
Download speed. Download speed (bytes per second).
``UP`` ``UL``
Upload speed and the number of uploaded bytes. Upload speed (bytes per second) and the number of uploaded bytes.
``ETA`` ``ETA``
Expected time to finish. Expected time to finish.
``TOTAL SPD`` When more than 1 download are going on, some of the information
The sum of download speed for all parallel downloads. described above will be omitted in order to show several download
information. And the overall download and upload speed are shown at
the beginning of the line.
When aria2 is allocating file space or validating checksum, it When aria2 is allocating file space or validating checksum, it
additionally prints the their progress: additionally prints the their progress:

View File

@ -96,18 +96,34 @@ protected:
} // namespace } // namespace
namespace { namespace {
void printSeedRatio(std::ostream& o, const SharedHandle<RequestGroup>& rg, void printSizeProgress(std::ostream& o, const SharedHandle<RequestGroup>& rg,
const TransferStat& stat) const TransferStat& stat,
const SizeFormatter& sizeFormatter)
{ {
if(rg->getCompletedLength() > 0) { #ifdef ENABLE_BITTORRENT
std::streamsize oldprec = o.precision(); if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
o << std::fixed << std::setprecision(1) !bittorrent::getTorrentAttrs(rg->getDownloadContext())
<< ((stat.allTimeUploadLength*10)/rg->getCompletedLength())/10.0 ->metadata.empty() && rg->downloadFinished()) {
<< std::setprecision(oldprec) o << "SEED(";
<< std::resetiosflags(std::ios::fixed); if(rg->getCompletedLength() > 0) {
} else { std::streamsize oldprec = o.precision();
o << "--"; o << std::fixed << std::setprecision(1)
} << ((stat.allTimeUploadLength*10)/rg->getCompletedLength())/10.0
<< std::setprecision(oldprec)
<< std::resetiosflags(std::ios::fixed);
} else {
o << "--";
}
o << ")";
} else
#endif // ENABLE_BITTORRENT
{
o << sizeFormatter(rg->getCompletedLength()) << "B/"
<< sizeFormatter(rg->getTotalLength()) << "B";
if(rg->getTotalLength() > 0) {
o << "(" << 100*rg->getCompletedLength()/rg->getTotalLength() << "%)";
}
}
} }
} // namespace } // namespace
@ -131,29 +147,11 @@ void printProgressCompact(std::ostream& o, const DownloadEngine* e,
++i, ++cnt) { ++i, ++cnt) {
TransferStat stat = (*i)->calculateStat(); TransferStat stat = (*i)->calculateStat();
o << "[#" << (*i)->getGID() << " "; o << "[#" << (*i)->getGID() << " ";
#ifdef ENABLE_BITTORRENT printSizeProgress(o, *i, stat, sizeFormatter);
if((*i)->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
!bittorrent::getTorrentAttrs((*i)->getDownloadContext())
->metadata.empty() && (*i)->downloadFinished()) {
o << "SEED(";
printSeedRatio(o, *i, stat);
o << ")";
} else
#endif // ENABLE_BITTORRENT
{
o << sizeFormatter((*i)->getCompletedLength()) << "B"
<< "/"
<< sizeFormatter((*i)->getTotalLength()) << "B";
if((*i)->getTotalLength() > 0) {
o << "("
<< 100*(*i)->getCompletedLength()/(*i)->getTotalLength()
<< "%)";
}
}
o << "]"; o << "]";
} }
if(cnt < groups.size()) { if(cnt < groups.size()) {
o << "(" << groups.size()-cnt << "more)"; o << "(+" << groups.size()-cnt << ")";
} }
} }
} // namespace } // namespace
@ -168,30 +166,8 @@ void printProgress
if(rg->getTotalLength() > 0 && stat.downloadSpeed > 0) { if(rg->getTotalLength() > 0 && stat.downloadSpeed > 0) {
eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.downloadSpeed; eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.downloadSpeed;
} }
o << "[#" << rg->getGID() << " "; o << "[#" << rg->getGID() << " ";
printSizeProgress(o, rg, stat, sizeFormatter);
#ifdef ENABLE_BITTORRENT
if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
!bittorrent::getTorrentAttrs(rg->getDownloadContext())->metadata.empty() &&
rg->downloadFinished()) {
o << "SEEDING(ratio:";
printSeedRatio(o, rg, stat);
o << ")";
} else
#endif // ENABLE_BITTORRENT
{
o << "SIZE:"
<< sizeFormatter(rg->getCompletedLength())
<< "B/"
<< sizeFormatter(rg->getTotalLength())
<< "B";
if(rg->getTotalLength() > 0) {
o << "("
<< 100*rg->getCompletedLength()/rg->getTotalLength()
<< "%)";
}
}
o << " CN:" o << " CN:"
<< rg->getNumConnection(); << rg->getNumConnection();
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
@ -199,18 +175,18 @@ void printProgress
if(btObj) { if(btObj) {
std::vector<SharedHandle<Peer> > peers; std::vector<SharedHandle<Peer> > peers;
btObj->peerStorage->getActivePeers(peers); btObj->peerStorage->getActivePeers(peers);
o << " SEED:" o << " SD:"
<< countSeeder(peers.begin(), peers.end()); << countSeeder(peers.begin(), peers.end());
} }
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
if(!rg->downloadFinished()) { if(!rg->downloadFinished()) {
o << " SPD:" o << " DL:"
<< sizeFormatter(stat.downloadSpeed) << "Bs"; << sizeFormatter(stat.downloadSpeed) << "B";
} }
if(stat.sessionUploadLength > 0) { if(stat.sessionUploadLength > 0) {
o << " UP:" o << " UL:"
<< sizeFormatter(stat.uploadSpeed) << "Bs" << sizeFormatter(stat.uploadSpeed) << "B"
<< "(" << sizeFormatter(stat.allTimeUploadLength) << "B)"; << "(" << sizeFormatter(stat.allTimeUploadLength) << "B)";
} }
if(eta > 0) { if(eta > 0) {
@ -309,20 +285,16 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
cp_ = global::wallclock(); cp_ = global::wallclock();
const SizeFormatter& sizeFormatter = *sizeFormatter_.get(); const SizeFormatter& sizeFormatter = *sizeFormatter_.get();
#ifdef __MINGW32__ // Some terminals (e.g., Windows terminal) prints next line when the
// Windows terminal cannot handle at the end of line (80 columns) // character reached at the last column.
// properly.
unsigned short int cols = 79; unsigned short int cols = 79;
#else // !__MINGW32__
unsigned short int cols = 80;
#endif // !__MINGW32__
if(isTTY_) { if(isTTY_) {
#ifndef __MINGW32__ #ifndef __MINGW32__
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
struct winsize size; struct winsize size;
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) { if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
cols = size.ws_col; cols = std::max(0, (int)size.ws_col-1);
} }
#endif // HAVE_TERMIOS_H #endif // HAVE_TERMIOS_H
#endif // !__MINGW32__ #endif // !__MINGW32__
@ -346,31 +318,21 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
} }
size_t numGroup = e->getRequestGroupMan()->countRequestGroup(); size_t numGroup = e->getRequestGroupMan()->countRequestGroup();
if(numGroup == 1) { if(numGroup == 1) {
SharedHandle<RequestGroup> firstRequestGroup = printProgress(o, e->getRequestGroupMan()->getRequestGroup(0), e,
e->getRequestGroupMan()->getRequestGroup(0); sizeFormatter);
printProgress(o, firstRequestGroup, e, sizeFormatter);
if(e->getRequestGroupMan()->countRequestGroup() > 1) {
o << "("
<< e->getRequestGroupMan()->countRequestGroup()-1
<< "more...)";
}
} else if(numGroup > 1) { } else if(numGroup > 1) {
// For more than 2 RequestGroups, use compact readout form // For more than 2 RequestGroups, use compact readout form
printProgressCompact(o, e, sizeFormatter); printProgressCompact(o, e, sizeFormatter);
} }
{ {
SharedHandle<FileAllocationEntry> entry = const SharedHandle<FileAllocationEntry>& entry =
e->getFileAllocationMan()->getPickedEntry(); e->getFileAllocationMan()->getPickedEntry();
if(entry) { if(entry) {
o << " [FileAlloc:" o << " [FileAlloc:#"
<< "#" << entry->getRequestGroup()->getGID() << " " << entry->getRequestGroup()->getGID() << " "
<< sizeFormatter(entry->getCurrentLength()) << sizeFormatter(entry->getCurrentLength()) << "B/"
<< "B/" << sizeFormatter(entry->getTotalLength()) << "B(";
<< sizeFormatter(entry->getTotalLength())
<< "B(";
if(entry->getTotalLength() > 0) { if(entry->getTotalLength() > 0) {
o << 100LL*entry->getCurrentLength()/entry->getTotalLength(); o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
} else { } else {
@ -378,23 +340,19 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
} }
o << "%)]"; o << "%)]";
if(e->getFileAllocationMan()->hasNext()) { if(e->getFileAllocationMan()->hasNext()) {
o << "(" o << "(+" << e->getFileAllocationMan()->countEntryInQueue() << ")";
<< e->getFileAllocationMan()->countEntryInQueue()
<< "waiting...)";
} }
} }
} }
#ifdef ENABLE_MESSAGE_DIGEST #ifdef ENABLE_MESSAGE_DIGEST
{ {
SharedHandle<CheckIntegrityEntry> entry = const SharedHandle<CheckIntegrityEntry>& entry =
e->getCheckIntegrityMan()->getPickedEntry(); e->getCheckIntegrityMan()->getPickedEntry();
if(entry) { if(entry) {
o << " [Checksum:#" o << " [Checksum:#"
<< entry->getRequestGroup()->getGID() << " " << entry->getRequestGroup()->getGID() << " "
<< sizeFormatter(entry->getCurrentLength()) << sizeFormatter(entry->getCurrentLength()) << "B/"
<< "B/" << sizeFormatter(entry->getTotalLength()) << "B(";
<< sizeFormatter(entry->getTotalLength())
<< "B(";
if(entry->getTotalLength() > 0) { if(entry->getTotalLength() > 0) {
o << 100LL*entry->getCurrentLength()/entry->getTotalLength(); o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
} else { } else {
@ -402,9 +360,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
} }
o << "%)]"; o << "%)]";
if(e->getCheckIntegrityMan()->hasNext()) { if(e->getCheckIntegrityMan()->hasNext()) {
o << "(" o << "(+" << e->getCheckIntegrityMan()->countEntryInQueue() << ")";
<< e->getCheckIntegrityMan()->countEntryInQueue()
<< "waiting...)";
} }
} }
} }

View File

@ -54,7 +54,7 @@ public:
return pickedEntry_; return pickedEntry_;
} }
SharedHandle<T> getPickedEntry() const const SharedHandle<T>& getPickedEntry() const
{ {
return pickedEntry_; return pickedEntry_;
} }