From b6b1138512d7cce226bca19aade3bd002a321340 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Mon, 23 Jun 2014 15:12:30 -0400 Subject: [PATCH] cleanup estimate size display and add GB --- gyb.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gyb.py b/gyb.py index 7f46a48..019622f 100644 --- a/gyb.py +++ b/gyb.py @@ -1278,20 +1278,23 @@ def main(argv): for working_messages in batch(messages_to_estimate, messages_at_once): messages_size = get_message_size(imapconn, working_messages) total_size = total_size + messages_size - if total_size > 1048576: - math_size = total_size/1048576 - print_size = "%.2fM" % math_size + if total_size > (1024 * 1024 * 1024): + math_size = total_size/(1024 * 1024 * 1024) + print_size = "%.2f GB" % math_size + elif total_size > (1024 * 1024): + math_size = total_size / (1024 * 1024) + print_size = "%.2f MB" % math_size elif total_size > 1024: math_size = total_size/1024 - print_size = "%.2fK" % math_size + print_size = "%.2f KB" % math_size else: - print_size = "%.2fb" % total_size + print_size = "%.2f bytes" % total_size if estimated_messages+messages_at_once < estimate_count: estimated_messages = estimated_messages + messages_at_once else: estimated_messages = estimate_count restart_line() - sys.stdout.write("Messages estimated: %s Estimated size: %s" % (estimated_messages, print_size)) + sys.stdout.write("Messages estimated: %s Estimated size: %s " % (estimated_messages, print_size)) sys.stdout.flush() time.sleep(1) print ""