forked from premiere/premiere-libtorrent
improve client_test rendering for checking and queued for checking torrents
This commit is contained in:
parent
018da0e29f
commit
0ab8dba84b
|
@ -311,8 +311,8 @@ std::string const& progress_bar(int progress, int width, char const* code = "33"
|
||||||
int progress_chars = (progress * width + 500) / 1000;
|
int progress_chars = (progress * width + 500) / 1000;
|
||||||
bar = esc(code);
|
bar = esc(code);
|
||||||
std::fill_n(std::back_inserter(bar), progress_chars, '#');
|
std::fill_n(std::back_inserter(bar), progress_chars, '#');
|
||||||
bar += esc("0");
|
|
||||||
std::fill_n(std::back_inserter(bar), width - progress_chars, '-');
|
std::fill_n(std::back_inserter(bar), width - progress_chars, '-');
|
||||||
|
bar += esc("0");
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,63 +1299,75 @@ int main(int argc, char* argv[])
|
||||||
if (s.num_incomplete >= 0) downloaders = s.num_incomplete;
|
if (s.num_incomplete >= 0) downloaders = s.num_incomplete;
|
||||||
else downloaders = s.list_peers - s.list_seeds;
|
else downloaders = s.list_peers - s.list_seeds;
|
||||||
|
|
||||||
snprintf(str, sizeof(str), "%-13s down: (%s%s%s) up: %s%s%s (%s%s%s) swarm: %4d:%4d"
|
if (s.state != torrent_status::queued_for_checking && s.state != torrent_status::checking_files)
|
||||||
" bw queue: (%d|%d) all-time (Rx: %s%s%s Tx: %s%s%s) seed rank: %x%s\n"
|
{
|
||||||
, (paused && !auto_managed)?"paused":(paused && auto_managed)?"queued":state_str[s.state]
|
snprintf(str, sizeof(str), "%-13s down: (%s%s%s) up: %s%s%s (%s%s%s) swarm: %4d:%4d"
|
||||||
, esc("32"), add_suffix(s.total_download).c_str(), term
|
" bw queue: (%d|%d) all-time (Rx: %s%s%s Tx: %s%s%s) seed rank: %x%s\n"
|
||||||
, esc("31"), add_suffix(s.upload_rate, "/s").c_str(), term
|
, (paused && !auto_managed)?"paused":(paused && auto_managed)?"queued":state_str[s.state]
|
||||||
, esc("31"), add_suffix(s.total_upload).c_str(), term
|
, esc("32"), add_suffix(s.total_download).c_str(), term
|
||||||
, downloaders, seeds
|
, esc("31"), add_suffix(s.upload_rate, "/s").c_str(), term
|
||||||
, s.up_bandwidth_queue, s.down_bandwidth_queue
|
, esc("31"), add_suffix(s.total_upload).c_str(), term
|
||||||
, esc("32"), add_suffix(s.all_time_download).c_str(), term
|
, downloaders, seeds
|
||||||
, esc("31"), add_suffix(s.all_time_upload).c_str(), term
|
, s.up_bandwidth_queue, s.down_bandwidth_queue
|
||||||
, s.seed_rank, esc("0"));
|
, esc("32"), add_suffix(s.all_time_download).c_str(), term
|
||||||
out += str;
|
, esc("31"), add_suffix(s.all_time_upload).c_str(), term
|
||||||
|
, s.seed_rank, esc("0"));
|
||||||
|
out += str;
|
||||||
|
|
||||||
if (torrent_index != active_torrent && s.state == torrent_status::seeding) continue;
|
if (torrent_index != active_torrent && s.state == torrent_status::seeding) continue;
|
||||||
char const* progress_bar_color = "33"; // yellow
|
char const* progress_bar_color = "33"; // yellow
|
||||||
if (s.state == torrent_status::checking_files
|
if (s.state == torrent_status::downloading_metadata)
|
||||||
|| s.state == torrent_status::downloading_metadata)
|
{
|
||||||
{
|
progress_bar_color = "35"; // magenta
|
||||||
progress_bar_color = "35"; // magenta
|
}
|
||||||
|
else if (s.current_tracker.empty())
|
||||||
|
{
|
||||||
|
progress_bar_color = "31"; // red
|
||||||
|
}
|
||||||
|
else if (sess_stat.has_incoming_connections)
|
||||||
|
{
|
||||||
|
progress_bar_color = "32"; // green
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(str, sizeof(str), " %-10s: %s%-10"PRId64"%s Bytes %6.2f%% %s\n"
|
||||||
|
, sequential_download?"sequential":"progress"
|
||||||
|
, esc("32"), s.total_done, esc("0")
|
||||||
|
, s.progress_ppm / 10000.f
|
||||||
|
, progress_bar(s.progress_ppm / 1000, terminal_width - 42, progress_bar_color).c_str());
|
||||||
|
out += str;
|
||||||
}
|
}
|
||||||
else if (s.current_tracker.empty())
|
else
|
||||||
{
|
{
|
||||||
progress_bar_color = "31"; // red
|
snprintf(str, sizeof(str), "%-13s %s\n"
|
||||||
}
|
, state_str[s.state]
|
||||||
else if (sess_stat.has_incoming_connections)
|
, progress_bar(s.progress_ppm / 1000, terminal_width - 42 - 20, "35").c_str());
|
||||||
{
|
out += str;
|
||||||
progress_bar_color = "32"; // green
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(str, sizeof(str), " %-10s: %s%-10"PRId64"%s Bytes %6.2f%% %s\n"
|
if (print_piece_bar && s.progress_ppm < 1000000 && s.progress > 0)
|
||||||
, sequential_download?"sequential":"progress"
|
|
||||||
, esc("32"), s.total_done, esc("0")
|
|
||||||
, s.progress_ppm / 10000.f
|
|
||||||
, progress_bar(s.progress_ppm / 1000, terminal_width - 42, progress_bar_color).c_str());
|
|
||||||
out += str;
|
|
||||||
|
|
||||||
if (print_piece_bar && s.progress_ppm < 1000000)
|
|
||||||
{
|
{
|
||||||
out += " ";
|
out += " ";
|
||||||
out += piece_bar(s.pieces, terminal_width - 7);
|
out += piece_bar(s.pieces, terminal_width - 7);
|
||||||
out += "\n";
|
out += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::posix_time::time_duration t = s.next_announce;
|
if (s.state != torrent_status::queued_for_checking && s.state != torrent_status::checking_files)
|
||||||
snprintf(str, sizeof(str)
|
{
|
||||||
, " peers: %s%d%s (%s%d%s) seeds: %s%d%s distributed copies: %s%4.2f%s "
|
boost::posix_time::time_duration t = s.next_announce;
|
||||||
|
snprintf(str, sizeof(str)
|
||||||
|
, " peers: %s%d%s (%s%d%s) seeds: %s%d%s distributed copies: %s%4.2f%s "
|
||||||
"sparse regions: %d download: %s%s%s next announce: %s%02d:%02d:%02d%s "
|
"sparse regions: %d download: %s%s%s next announce: %s%02d:%02d:%02d%s "
|
||||||
"tracker: %s%s%s\n"
|
"tracker: %s%s%s\n"
|
||||||
, esc("37"), s.num_peers, esc("0")
|
, esc("37"), s.num_peers, esc("0")
|
||||||
, esc("37"), s.connect_candidates, esc("0")
|
, esc("37"), s.connect_candidates, esc("0")
|
||||||
, esc("37"), s.num_seeds, esc("0")
|
, esc("37"), s.num_seeds, esc("0")
|
||||||
, esc("37"), s.distributed_copies, esc("0")
|
, esc("37"), s.distributed_copies, esc("0")
|
||||||
, s.sparse_regions
|
, s.sparse_regions
|
||||||
, esc("32"), add_suffix(s.download_rate, "/s").c_str(), esc("0")
|
, esc("32"), add_suffix(s.download_rate, "/s").c_str(), esc("0")
|
||||||
, esc("37"), t.hours(), t.minutes(), t.seconds(), esc("0")
|
, esc("37"), t.hours(), t.minutes(), t.seconds(), esc("0")
|
||||||
, esc("36"), s.current_tracker.c_str(), esc("0"));
|
, esc("36"), s.current_tracker.c_str(), esc("0"));
|
||||||
out += str;
|
out += str;
|
||||||
|
}
|
||||||
|
|
||||||
if (torrent_index != active_torrent) continue;
|
if (torrent_index != active_torrent) continue;
|
||||||
active_handle = h;
|
active_handle = h;
|
||||||
|
|
Loading…
Reference in New Issue