Merge branch 'devel' into login
Conflicts: speedtest_cli.py
This commit is contained in:
commit
cbba7ef3e7
43
.travis.yml
43
.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:
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
# Pull Requests
|
||||
|
||||
Pull requests should be made against the `working` branch.
|
||||
## 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. 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
|
||||
|
||||
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
|
||||
|
||||
|
|
20
README.rst
20
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
|
||||
--------
|
||||
|
@ -65,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
|
||||
|
|
75
setup.py
75
setup.py
|
@ -1,13 +1,67 @@
|
|||
#!/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
|
||||
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'
|
||||
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:
|
||||
f = codecs.open('README.rst', encoding='utf-8')
|
||||
long_description = f.read()
|
||||
f.close()
|
||||
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 +74,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',
|
||||
]
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.7'
|
||||
|
||||
# Some global variables we use
|
||||
source = None
|
||||
|
@ -495,6 +495,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('--uid', help='Specify speedtest.net username')
|
||||
parser.add_argument('--pw', help='Specify speedtest.net password')
|
||||
parser.add_argument('--share', action='store_true',
|
||||
|
@ -597,6 +601,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)
|
||||
|
@ -642,7 +659,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 = []
|
||||
|
@ -654,7 +672,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 '
|
||||
|
|
Loading…
Reference in New Issue