From e4f493954a756807271c8bbd641aa7e83ba2c53e Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 18 Feb 2014 09:25:22 -0600 Subject: [PATCH 01/14] Update to new pypip.in links --- README.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 7c30edb..3fe1cd4 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,14 @@ Command line interface for testing internet bandwidth using speedtest.net .. image:: https://pypip.in/v/speedtest-cli/badge.png - :target: https://crate.io/packages/speedtest-cli + :target: https://pypi.python.org/pypi/speedtest-cli/ + :alt: Latest Version .. image:: https://pypip.in/d/speedtest-cli/badge.png - :target: https://crate.io/packages/speedtest-cli + :target: https://pypi.python.org/pypi//speedtest-cli/ + :alt: Downloads +.. image:: https://pypip.in/license/speedtest-cli/badge.png + :target: https://pypi.python.org/pypi/speedtest-cli/ + :alt: License Versions -------- From 3d55c7d91e4b62a08c180f953f1e54983a64e875 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 20 Feb 2014 17:07:53 -0600 Subject: [PATCH 02/14] Fix double slash --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3fe1cd4..7371a11 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ speedtest.net :target: https://pypi.python.org/pypi/speedtest-cli/ :alt: Latest Version .. image:: https://pypip.in/d/speedtest-cli/badge.png - :target: https://pypi.python.org/pypi//speedtest-cli/ + :target: https://pypi.python.org/pypi/speedtest-cli/ :alt: Downloads .. image:: https://pypip.in/license/speedtest-cli/badge.png :target: https://pypi.python.org/pypi/speedtest-cli/ From f559d79ded28984859d15096af021e954886cd19 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 25 Feb 2014 15:11:04 -0600 Subject: [PATCH 03/14] Don't try testing python2.4, maybe we can use a drone server for this --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84a0d00..6984d70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,12 @@ script: - python speedtest_cli.py - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then curl -s http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 | tar xj; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then cd Python-2.4.6; ./configure --prefix=$HOME/virtualenv/python2.4 > /dev/null 2>&1; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make > /dev/null 2>&1; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make install > /dev/null 2>&1; cd ..; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 -V; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 ./speedtest_cli.py; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then curl -s http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 | tar xj; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then cd Python-2.4.6; ./configure --prefix=$HOME/virtualenv/python2.4 > /dev/null 2>&1; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make > /dev/null 2>&1; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make install > /dev/null 2>&1; cd ..; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 -V; fi +# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 ./speedtest_cli.py; fi notifications: email: From e6913368ef2f2e5a1382da9a80fd742d2249b80c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 26 Feb 2014 07:34:11 -0600 Subject: [PATCH 04/14] 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 ' From 8a308040a9c1d34923622735ac5fe147432f2cfa Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 17 Apr 2014 10:22:05 -0500 Subject: [PATCH 05/14] Update CONTRIBUTING.md --- CONTRIBUTING.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a1e7808..0febefc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,20 @@ # Pull Requests -Pull requests should be made against the `working` branch. +Pull requests should be made against the `devel` branch. Pull requests should be made from a git feature branch. Pull requests will not be accepted that: + +1. Are not made against the `devel` branch +1. Are submitted from a branch named `devel` +1. Don't pass pep8/pyflakes/flake8 +1. Do not work with Python 2.4-3.4 or pypy +1. Add python modules not included with the Python standard library # Coding Guidelines -In general, I follow strict pep8 and pyflakes. All code must pass these tests. Since we support python 2.4-3.4, pyflakes reports unknown names in python 3. pyflakes is run in python 2.7 only in my tests. +In general, I follow strict pep8 and pyflakes. All code must pass these tests. Since we support python 2.4-3.4 and pypy, pyflakes reports unknown names in python 3. pyflakes is run in python 2.7 only in my tests. # Supported Python Versions -All code needs to support Python 2.4-3.4. +All code needs to support Python 2.4-3.4 and pypy. # Permitted Python Modules From 3e9c6e3532db97f78883c7e93a5e643d9324fe41 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 17 Apr 2014 10:25:21 -0500 Subject: [PATCH 06/14] Better testing using tox --- .travis.yml | 43 ++++++++++++++++++++++++------------------- tox.ini | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index 6984d70..ddaa43b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,35 @@ ---- language: python python: - - 2.6 - 2.7 - - 3.2 - - 3.3 - - pypy + +env: + - TOXENV=py24 + - TOXENV=py25 + - TOXENV=py26 + - TOXENV=py27 + - TOXENV=py31 + - TOXENV=py32 + - TOXENV=py33 + - TOXENV=py34 + - TOXENV=pypy + - TOXENV=flake8 + +before_install: + - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py3[14])") != 0 ]]; then sudo add-apt-repository -y ppa:fkrull/deadsnakes; fi; + - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py3[14])") != 0 ]]; then sudo apt-get update -qq; fi; + - if [[ "$TOXENV" == "py24" ]]; then sudo apt-get install -y python2.4; fi; + - if [[ "$TOXENV" == "py25" ]]; then sudo apt-get install -y python2.5; fi; + - if [[ "$TOXENV" == "py31" ]]; then sudo apt-get install -y python3.1; fi; + - if [[ "$TOXENV" == "py34" ]]; then sudo apt-get install -y python3.4; fi; + - if [[ "$TOXENV" == "pypy" ]]; then sudo apt-get install -y pypy; fi; install: - - pip install . - - pip install pep8 pyflakes + - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") != 0 ]]; then pip install virtualenv==1.7.2 tox==1.3; fi; + - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") == 0 ]]; then pip install tox; fi; script: - - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pep8 --show-source speedtest_cli.py; fi - - - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pyflakes speedtest_cli.py; fi - - - python speedtest_cli.py - -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then curl -s http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 | tar xj; fi -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then cd Python-2.4.6; ./configure --prefix=$HOME/virtualenv/python2.4 > /dev/null 2>&1; fi -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make > /dev/null 2>&1; fi -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then make install > /dev/null 2>&1; cd ..; fi -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 -V; fi -# - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then ~/virtualenv/python2.4/bin/python2.4 ./speedtest_cli.py; fi + - tox notifications: email: diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..8d0ebc2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +skipsdist=true + +[testenv] +commands = + {envpython} -V + {envpython} speedtest_cli.py + +[testenv:flake8] +basepython=python +deps=flake8 +commands = + {envpython} -V + flake8 speedtest_cli.py + +[testenv:pypy] +commands = + pypy -V + pypy speedtest_cli.py From 23fba2520a857dd7b8e7512d68bddb09d805f4fb Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 17 Apr 2014 16:13:55 -0500 Subject: [PATCH 07/14] When using --mini and no extension is found, try all of the standard upload extensions. Fixes #62 --- speedtest_cli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/speedtest_cli.py b/speedtest_cli.py index 297702e..5c47d2e 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -543,6 +543,19 @@ def speedtest(): text = f.read() f.close() extension = re.findall('upload_extension: "([^"]+)"', text.decode()) + if not extension: + for ext in ['php', 'asp', 'aspx', 'jsp']: + try: + f = urlopen('%s/speedtest/upload.%s' % (args.mini, ext)) + except: + pass + else: + data = f.read().strip() + if (f.code == 200 and + len(data.splitlines()) == 1 and + re.match('size=[0-9]', data)): + extension = [ext] + break if not urlparts or not extension: print_('Please provide the full URL of your Speedtest Mini server') sys.exit(1) From 20c9882b090c211859f3c3649d8dd9f0d35057ca Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 10:22:09 -0500 Subject: [PATCH 08/14] Improve setup.py --- setup.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 554b628..606a4e1 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,62 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright 2012-2014 Matt Martz +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. -import setuptools +import os +import re +import codecs -setuptools.setup( +from setuptools import setup + +here = os.path.abspath(os.path.dirname(__file__)) + + +# Read the version number from a source file. +# Why read it, and not import? +# see https://groups.google.com/d/topic/pypa-dev/0PkjVpcxTzQ/discussion +def find_version(*file_paths): + # Open in Latin-1 so that we avoid encoding errors. + # Use codecs.open for Python 2 compatibility + with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f: + version_file = f.read() + + # The version line must have the form + # __version__ = 'ver' + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") + + +# Get the long description from the relevant file +try: + with codecs.open('README.rst', encoding='utf-8') as f: + long_description = f.read() +except: + long_description = '' + + +setup( name='speedtest-cli', - version='0.2.5', + version=find_version('speedtest_cli.py'), description=('Command line interface for testing internet bandwidth using ' 'speedtest.net'), - long_description=open('README.rst').read(), + long_description=long_description, + keywords='speedtest speedtest.net', author='Matt Martz', author_email='matt@sivel.net', url='https://github.com/sivel/speedtest-cli', @@ -20,9 +69,20 @@ setuptools.setup( ] }, classifiers=[ + 'Development Status :: 5 - Production/Stable', 'Programming Language :: Python', 'Environment :: Console', 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent' + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.4', + 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', ] ) From 8d1cf7ac1ee0181d85443036b6ca59f0be794b0c Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 10:22:22 -0500 Subject: [PATCH 09/14] Bump version to 0.2.6 --- speedtest_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/speedtest_cli.py b/speedtest_cli.py index 5c47d2e..d5d5a4a 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright 2013 Matt Martz +# Copyright 2012-2014 Matt Martz # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -15,7 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. -__version__ = '0.2.5' +__version__ = '0.2.6' # Some global variables we use source = None From 966fd2c86d0d02b73acfb42ce5384dab45bfbb1a Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 10:24:31 -0500 Subject: [PATCH 10/14] Clean up CONTRIBUTING.md --- CONTRIBUTING.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0febefc..d73a580 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,18 @@ # Pull Requests -Pull requests should be made against the `devel` branch. Pull requests should be made from a git feature branch. Pull requests will not be accepted that: +## Pull requests should be + +1. Made against the `devel` branch. +1. Made from a git feature branch. + +## Pull requests will not be accepted that 1. Are not made against the `devel` branch 1. Are submitted from a branch named `devel` -1. Don't pass pep8/pyflakes/flake8 +1. Do not pass pep8/pyflakes/flake8 1. Do not work with Python 2.4-3.4 or pypy 1. Add python modules not included with the Python standard library +1. Are made by editing files via the GitHub website # Coding Guidelines From 8e0d5eaec84cffc991b8841f5b9df272f30437c3 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 10:31:23 -0500 Subject: [PATCH 11/14] python < 2.6 does not have the 'with' statement --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 606a4e1..6993e1f 100644 --- a/setup.py +++ b/setup.py @@ -30,8 +30,12 @@ here = os.path.abspath(os.path.dirname(__file__)) def find_version(*file_paths): # Open in Latin-1 so that we avoid encoding errors. # Use codecs.open for Python 2 compatibility - with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f: + try: + f = codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') version_file = f.read() + f.close() + except: + raise RuntimeError("Unable to find version string.") # The version line must have the form # __version__ = 'ver' @@ -44,8 +48,9 @@ def find_version(*file_paths): # Get the long description from the relevant file try: - with codecs.open('README.rst', encoding='utf-8') as f: - long_description = f.read() + f = codecs.open('README.rst', encoding='utf-8') + long_description = f.read() + f.close() except: long_description = '' From 807df51c834a395904aac10d2d3d4d174f265303 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 11:50:11 -0500 Subject: [PATCH 12/14] Update usage in README --- README.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 7371a11..e068d2c 100644 --- a/README.rst +++ b/README.rst @@ -70,15 +70,18 @@ Usage :: $ speedtest-cli -h - usage: speedtest-cli [-h] [--share] [--simple] [--list] [--server SERVER] - [--mini MINI] [--source SOURCE] [--version] - + usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list] + [--server SERVER] [--mini MINI] [--source SOURCE] + [--version] + Command line interface for testing internet bandwidth using speedtest.net. -------------------------------------------------------------------------- https://github.com/sivel/speedtest-cli - + optional arguments: -h, --help show this help message and exit + --bytes Display values in bytes instead of bits. Does not affect + the image generated by --share --share Generate and provide a URL to the speedtest.net share results image --simple Suppress verbose output, only show basic information From 5bbc3e8bb05e25671792ff7d158759cbbbe8c643 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 11:52:26 -0500 Subject: [PATCH 13/14] Update man page with --bytes argument --- speedtest-cli.1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/speedtest-cli.1 b/speedtest-cli.1 index c7853b5..eb20ea7 100644 --- a/speedtest-cli.1 +++ b/speedtest-cli.1 @@ -1,4 +1,4 @@ -.TH "speedtest-cli" 1 "2014-01-26" "speedtest-cli" +.TH "speedtest-cli" 1 "2014-04-23" "speedtest-cli" .SH NAME speedtest\-cli \- Test your bandwidth througput using speedtest.net .SH SYNOPSIS @@ -23,6 +23,11 @@ Displays usage for the tool. .B Options +\fB\-\-bytes\fR +.RS +Display values in bytes instead of bits. Does not affect the image generated by \-\-share +.RE + \fB\-\-share\fR .RS Generate and provide a URL to the speedtest.net share results image From f1647f2c9e40a9542c934741558e71730a2c1be5 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 11:52:57 -0500 Subject: [PATCH 14/14] Bump version to 0.2.7 --- speedtest_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speedtest_cli.py b/speedtest_cli.py index d5d5a4a..6c89b1d 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -15,7 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. -__version__ = '0.2.6' +__version__ = '0.2.7' # Some global variables we use source = None