-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheasyraikit.py
More file actions
37 lines (32 loc) · 744 Bytes
/
easyraikit.py
File metadata and controls
37 lines (32 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import requests
from time import sleep
from easyraikit_config import *
class Rai:
def __getattr__(self, name, *args):
def function (*args):
global server
if server:
request = {}
request["action"] = name
if args:
for key, value in args[0].items():
request[key] = value
try:
r = requests.post(server, data = json.dumps(request)).json()
if "error" not in r:
return(r)
else:
print(r["error"])
return None
except:
sleep(0.5)
r = requests.post(server, data = json.dumps(request)).json()
if "error" not in r:
return(r)
else:
print(r["error"])
return None
else:
print("Wrong server configuration.")
return function