25 lines
931 B
Python
25 lines
931 B
Python
from random import Random;
|
|
from jsonrpcclient import Request
|
|
from jsonrpcclient.http_client import HTTPClient
|
|
import sys,os
|
|
class TRS(Random):
|
|
def __init__(self,apikey_path):
|
|
try:
|
|
with open (apikey_path, 'r') as f:
|
|
apikey=f.readline()
|
|
except:
|
|
print("Please provide a file that contains only your apikey with the -a option, if no option is provided the script assumes that the apikey file has this path: " + args.apikey)
|
|
exit(1)
|
|
#Prevent program segments from blabbering to stdout/stderr
|
|
with open(os.devnull, "w") as devnull:
|
|
old_stdout = sys.stdout
|
|
sys.stdout = devnull
|
|
old_stderr = sys.stderr
|
|
sys.stderr = devnull
|
|
client = HTTPClient("https://api.random.org/json-rpc/2/invoke")
|
|
response = client.send(Request("generateIntegers", apiKey=apikey,n="1",min='1',max="1000000000"))
|
|
seed=response["random"]["data"]
|
|
sys.stdout = old_stdout
|
|
sys.stderr = old_stderr
|
|
super().seed(seed[0])
|