Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to install via pip #1

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ old/
*~
~
*.pyc

# Autogenerated stuff from build
*.egg
*.egg-info
build
dist
eggs
File renamed without changes.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE.txt
111 changes: 80 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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).

Expand All @@ -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
Expand All @@ -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 <directory-of-tespeed-source>`

####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`
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e git+https://github.com/Janhouse/SocksiPy#egg=SocksiPy-digsby
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
71 changes: 71 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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 = '[email protected]',
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',
],
)
8 changes: 6 additions & 2 deletions tespeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
args.suppress=None
args.store=None

from SocksiPy import socks
import socks
import socket

# Magic!
Expand Down Expand Up @@ -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).')
Expand All @@ -708,3 +709,6 @@ def main(args):

args = parser.parse_args()
main(args)

if __name__ == '__main__':
init()