From e6913368ef2f2e5a1382da9a80fd742d2249b80c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 26 Feb 2014 07:34:11 -0600 Subject: [PATCH] Support output in bytes using the --bytes argument --- speedtest_cli.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/speedtest_cli.py b/speedtest_cli.py index 1a6c0ca..297702e 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -450,6 +450,10 @@ def speedtest(): parser.add_argument = parser.add_option except AttributeError: pass + parser.add_argument('--bytes', dest='units', action='store_const', + const=('bytes', 1), default=('bits', 8), + help='Display values in bytes instead of bits. Does ' + 'not affect the image generated by --share') parser.add_argument('--share', action='store_true', help='Generate and provide a URL to the speedtest.net ' 'share results image') @@ -584,7 +588,8 @@ def speedtest(): dlspeed = downloadSpeed(urls, args.simple) if not args.simple: print_() - print_('Download: %0.2f Mbit/s' % ((dlspeed / 1000 / 1000) * 8)) + print_('Download: %0.2f M%s/s' % + ((dlspeed / 1000 / 1000) * args.units[1], args.units[0])) sizesizes = [int(.25 * 1000 * 1000), int(.5 * 1000 * 1000)] sizes = [] @@ -596,7 +601,8 @@ def speedtest(): ulspeed = uploadSpeed(best['url'], sizes, args.simple) if not args.simple: print_() - print_('Upload: %0.2f Mbit/s' % ((ulspeed / 1000 / 1000) * 8)) + print_('Upload: %0.2f M%s/s' % + ((ulspeed / 1000 / 1000) * args.units[1], args.units[0])) if args.share and args.mini: print_('Cannot generate a speedtest.net share results image while '