-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrocketpool.py
executable file
·32 lines (23 loc) · 1020 Bytes
/
rocketpool.py
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
#!/usr/bin/env python3
import subprocess
import json
def getArtifacts(d):
cmdFmt = "docker exec rocketpool_api /go/bin/rocketpool api minipool get-vanity-artifacts {} 0"
if d == "16":
cmd = cmdFmt.format("16000000000000000000")
else:
cmd = cmdFmt.format("32000000000000000000")
if not cmd:
raise Exception("Invalid deposit amount. \"16\" and \"32\" are the only supported amounts")
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
if not output:
raise Exception("Failed to run command")
parsed = json.loads(output)
if not parsed:
raise Exception(f"Error parsing JSON: {output}")
if "error" in parsed and parsed["error"] != "":
raise Exception(f"Error from rocketpool api: {parsed['error']}")
if parsed["status"] != "success":
raise Exception(f"Unknown error occured handling response {output}")
return parsed
print(json.dumps({"atlas": getArtifacts("16")}, indent=4, sort_keys=True))