diff --git a/.gitignore b/.gitignore index 2bc1b44..c1abeda 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,10 @@ old/ *~ ~ *.pyc + +# Autogenerated stuff from build +*.egg +*.egg-info +build +dist +eggs diff --git a/MIT-LICENSE.txt b/LICENSE.txt similarity index 100% rename from MIT-LICENSE.txt rename to LICENSE.txt diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f2b6663 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include LICENSE.txt diff --git a/README.md b/README.md index 4ed132f..a8b8cda 100644 --- a/README.md +++ b/README.md @@ -25,42 +25,70 @@ Tespeed (terminal speedtest) - Copyright 2012 Janis Jansons (janis.jansons@janho If you don't need testing through socks proxy, go check it out. :) -Requirements: +##Requirements: - This script requires recent Python (preferably 2.7 or newer) and Python2 - modules lxml and argparse. - Install python-lxml and python-argparse (Debian) - $ sudo apt-get install python-lxml python-argparse +##Installation: - or python2-lxml (Archlinux). +###Via Pip (**Coming Soon**) -Installation: +If you have pip installed, just do `pip install tespeed` - If you have Debian, you might have to change the python executable in tuper.py - or create a symlink for your existing python2.x executable by doing: - - sudo ln -s /usr/bin/python2.7 /usr/bin/python2 - - If you have python2.6 then replace python2.7 with python2.6. - - +###Manually via git - When doing the checkout, remember to pull submodules. - - If you have a decent git version (1.6.5 and up), get everything by doing: +###Requirements + +Since this is a manual installation, the script requires recent Python +(preferably 2.7 or newer) and Python2 modules `lxml` and `argparse`. +Install python-lxml and python-argparse (Debian) - git clone --recursive git://github.com/Janhouse/tespeed.git +``` +$ sudo apt-get install python-lxml python-argparse +``` - Otherwise do: +or python2-lxml (Archlinux). + + +If you have Debian, you might have to change the python executable in tuper.py +or create a symlink for your existing python2.x executable by doing: + +``` +sudo ln -s /usr/bin/python2.7 /usr/bin/python2 +``` - git clone git://github.com/Janhouse/tespeed.git - cd tespeed - git submodule init - git submodule update +If you have python2.6 then replace python2.7 with python2.6. + +#####Grabbing the custom SocksiPy-digsby dependency + +Finally, _IF you are doing the manual step_, the app needs a custom version of the `SocksiPy-digsby` library +that needs to be installed for tespeed to work and so the following should be run: + +``` +pip install -r requirements.txt +``` +This will grab the custom dependency and install it in the path -Usage: +###Grabbing Source + +When doing the checkout, remember to pull submodules. + +If you have a decent git version (1.6.5 and up), get everything by doing: + +``` +git clone --recursive git://github.com/Janhouse/tespeed.git +``` + +Otherwise do: + +``` +git clone git://github.com/Janhouse/tespeed.git +cd tespeed +git submodule init +git submodule update +``` + +##Usage: usage: tespeed.py [-h] [-ls [LISTSERVERS]] [-w] [-s] [-mib] [-n [SERVERCOUNT]] [-p [USE_PROXY]] [-ph [PROXY_HOST]] [-pp [PROXY_PORT]] @@ -96,7 +124,7 @@ Usage: weak hardware like RaspberryPi. (Default: 10240) -What the script does: +##What the script does: * Loads config from speedtest.net (http://speedtest.net/speedtest-config.php). @@ -116,14 +144,15 @@ What the script does: * Can measure through SOCKS proxy. -Logging to file +###Logging to file - Execute manually or add to crontab: - - echo $(date +"%Y-%m-%d,%H:%M"),$(./tespeed.py -w) >> speedtest-log.txt +Execute manually or add to crontab: +``` +echo $(date +"%Y-%m-%d,%H:%M"),$(./tespeed.py -w) >> speedtest-log.txt +``` -TODO (ideas): +##TODO (ideas): * Make it less messy. * Send found results to speedtest.net API (needs some hash?) and get the link @@ -135,4 +164,24 @@ TODO (ideas): actively sendong/receiving data at the same time. (Should provide more precise test results.) +##Contributing and Testing + +_**Warning:** Section incomplete_ + +####Initial Steps: +1. To develop, package and upload, you need: [twine](https://github.com/pypa/twine) +2. You also need to have an account with PyPi setup +3. Setup your `.pypirc` file. [See here on how](https://docs.python.org/2/distutils/packageindex.html#pypirc) + +####Testing +To run and test locally, feel free to just install from local source via: `pip install -e ` + +####Uploading: +* Create the `PKG-INFO` that is used to describe your package to pypi registry with `python setup.py egg_info` +* Upload `tespeed.egg-info/PKG-INFO` via the [PyPi form on the website](https://pypi.python.org/pypi?%3Aaction=submit_form) +* To package, run: `python setup.py sdist bdist_wheel` +* To upload, run: `twine upload dist/*` (please upload and test with `-r pypitest` first before uploading directly to pypi) + +If you want to test if everything worked (assuming you uploaded to _pypitest_ first): +* Just run `pip install -i https://testpypi.python.org/pypi tespeed` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..74d4305 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +-e git+https://github.com/Janhouse/SocksiPy#egg=SocksiPy-digsby diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b88034e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +description-file = README.md diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..4dc4745 --- /dev/null +++ b/setup.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from setuptools import setup +from subprocess import call + +# A bit hacky but this needs to be done to install +# any dependency in VCS and non PyPi location as part of +# one `pip install` command +with open('./requirements.txt') as f: + deps = f.read().splitlines() + + for dep in deps: + call(['pip', 'install'] + dep.split(' ')) + +setup( + name = 'tespeed', + + # Since this package is simple, just reference the .py file + # directly instead of specifying a particular package + py_modules = ['tespeed'], + + # TODO: Make this dynamically retrieved from a source file for easier maintenance + version = '1.1.0', + description = 'Terminal network speed test that uses servers from Speedtest.net. It uses nearest test server but can also use one manually specified by the user', + + license = 'MIT', + + author = 'Janis Jansons', + author_email = 'janis.jansons@janhouse.lv', + url = 'https://github.com/gauthamchandra/tespeed', + + download_url = 'https://github.com/Janhouse/tespeed/tarball/1.1', + keywords = 'speedtest.net network speed', + + # dependencies + # TODO: Add upper and lower bound versions of compatibility so bleeding edge dependency doesn't break + # the app + install_requires = ['lxml', 'argparse'], + + # More for easy_install than pip + dependency_links = [ + 'https://github.com/Janhouse/SocksiPy/tarball/master#egg=SocksiPy-digsby' + ], + + entry_points = { + 'console_scripts': [ + 'tespeed=tespeed:init' + ] + }, + + # Full list here: https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers = [ + # Lifecycle of this version + 'Development Status :: 5 - Production/Stable', + + # The license the software is under + 'License :: OSI Approved :: MIT License', + + # What category and audience it may fall under + 'Programming Language :: Python', + 'Environment :: Console', + 'Operating System :: OS Independent', + 'Topic :: System :: Networking', + 'Topic :: Utilities', + 'Intended Audience :: System Administrators', + + # Supported versions + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 2 :: Only', + ], +) diff --git a/tespeed.py b/tespeed.py index f7290d5..6f74793 100755 --- a/tespeed.py +++ b/tespeed.py @@ -8,7 +8,7 @@ args.suppress=None args.store=None -from SocksiPy import socks +import socks import socket # Magic! @@ -684,7 +684,8 @@ def main(args): print_debug("\nTesting stopped.\n") #raise -if __name__ == '__main__': +# TODO: The help text should be offloaded to a man page +def init(): parser = argparse.ArgumentParser(description='TeSpeed, CLI SpeedTest.net') parser.add_argument('server', nargs='?', type=str, default='', help='Use the specified server for testing (skip checking for location and closest server).') @@ -708,3 +709,6 @@ def main(args): args = parser.parse_args() main(args) + +if __name__ == '__main__': + init()