Module randomorg

Module randomorg

source code

Module to access random.org for random numbers

Examples

Dice

>>> import randomorg
>>> ro = randomorg.RandomOrg()
>>> if ro.checkQuota():
...:    # Roll a dice
...:    print ro.getInteger(2, 1, 6)

Feed /dev/random

>>> import os
>>> import randomorg
>>> rfp = "/dev/random"
>>> ro = randomorg.RandomOrg()
>>>
>>> if os.access(rfp, os.W_OK):
...:    fp = open(rfp, "a")
...:    # Old API uses checkBuffer instead of checkQuota
...:    if ro.checkBuffer():
...:        for bytes in ro.getRandomByte():
...:            fp.write(bytes)
...:    close(fp)

Version: 0.01

Author: Ali Polatel <polatel@itu.edu.tr>

License: GPL-3

Classes
  RandomOrg
Main class to interact with random.org
  RandomOrgHTTPError
HTTPError that also prints out random.org error messages.
Functions
 
getPage(uri, headers)
Get an url, raise RandomOrgHTTPError on failure.
source code
Function Details

getPage(uri, headers)

source code 

Get an url, raise RandomOrgHTTPError on failure.

Parameters:
  • uri (str) - The requested url address.
  • headers (dict) - HTTP Headers passed to urllib2.Request()