Coder Social home page Coder Social logo

onion-py's Introduction

OnionPy

A comprehensive pure-Python wrapper for the OnionOO Tor status API, with memcached support to cache queried data.

Installing OnionPy

You can install onion-py manually by doing the following (requires setuptools!)::

git clone https://github.com/duk3luk3/onion-py.git
cd onion-py
#run tests if desired
PYTHONPATH=. python bin/onion.py test
sudo python setup.py install

For the optional memcached support, install pymemcache and six::

sudo pip install six
sudo pip install https://github.com/pinterest/pymemcache.git

The package is also on Pypi.

Beware: OnionPy has been developed and tested exclusively with Python 3. Please let Python 2 rest in peace forevermore. OnionPy is compatible with Python 2.7 upwards.

Usage

>>> from onion_py.manager import Manager
>>> from onion_py.caching import OnionSimpleCache
>>> manager = Manager(OnionSimpleCache())
>>> s = manager.query('summary', limit=4)
>>> s.relays[0].fingerprint
'695D027F728A3B95D0D7F6464D63F82229BFA361'
>>> s.relays[0].nickname
'GREATWHITENORTH'

Accepted Queries

Summary, details, bandwidth, weights, clients, uptime

>>> s = manager.query('summary', limit=4)
>>> s = manager.query('details', limit=4)
>>> s = manager.query('bandwidth', limit=4)
>>> s = manager.query('weights', limit=4)
>>> s = manager.query('clients', limit=4)
>>> s = manager.query('uptime', limit=4)

License

BSD 3-clause. See LICENSE.
Portions of this work obviously belong to to OnionOO and therefore the Tor Project. See ONIONOO-LICENSE.

onion-py's People

Contributors

alexrashed avatar baumanno avatar duk3luk3 avatar shockwaver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

onion-py's Issues

Get uptime in date values

Hello, how can i get an uptime of any relay (days/hours). Wrapper gives me only this (graph values):

>>> print u.relays[1].uptime
{u'1_month': <onion_py.objects.GraphHistory instance at 0x7f5a1d9c0f80>, u'3_months': <onion_py.objects.GraphHistory instance at 0x7f5a1d9c6128>, u'5_years': <onion_py.objects.GraphHistory instance at 0x7f5a1d9c6050>, u'1_week': <onion_py.objects.GraphHistory instance at 0x7f5a1d9c6098>, u'1_year': <onion_py.objects.GraphHistory instance at 0x7f5a1d9c0fc8>}

Is it possible to get uptime in days/hours? i'm racking my brains..

Incompatible with OnionOO Document Version 3

Installed with pip install onionpy, got onionpy-0.3.1. Tried the usage example from the README, but the query failed with the following traceback:

▶ python
Python 3.5.1 (default, Dec  7 2015, 21:59:08) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from onion_py.manager import Manager
>>> from onion_py.caching import OnionSimpleCache
>>> manager = Manager(OnionSimpleCache())
>>> s = manager.query('summary', limit=4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/garrett/code/freedomofpress/tor_relay_db/env/lib/python3.5/site-packages/onion_py/manager.py", line 167, in query
    raise MajorVersionMismatchError("Received OnionOO Document with version {}, this library only supports up to version {}".format(versions[0],self.OOO_VERSION_MAJOR))
onion_py.manager.MajorVersionMismatchError: Received OnionOO Document with version 3, this library only supports up to version 2
>>> 

Version Mismatch with version 4

Hello,

Thanks for a great library. I just started receiving this error. I think OnionOO must have updated to version 4 which OnionPy does not support yet? Thanks!
version_mismatch

Version Mismatch with version 7

I think I’m having the same issue as a previous thread, substituting in version 7 and version 4 respectively. Will the fix mention in the previous thread titled "Version Mismatch with version 4" work still?

"onion_py.manager.MajorVersionMismatchError: Received OnionOO Document with version 7, this library only supports up to version 4"

Any help would be greatly appreciated.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.