-
Notifications
You must be signed in to change notification settings - Fork 14
/
gateways_creation_tui.py
executable file
·67 lines (59 loc) · 2.46 KB
/
gateways_creation_tui.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
from lib import rpclib, tuilib
import os
import time
header = "\
_____ _ _____ _____ \n\
| __ \ | | / __ \/ __ \\\n\
| | \/ __ _| |_ _____ ____ _ _ _ ___| / \/| / \/\n\
| | __ / _` | __/ _ \ \ /\ / / _` | | | / __| | | | \n\
| |_\ \ (_| | || __/\ V V / (_| | |_| \__ \ \__/\| \__/\\\n\
\____/\__,_|\__\___| \_/\_/ \__,_|\__, |___/\____/ \____/\n\
__/ | \n\
|___/ \n"
menuItems = [
{"Check current connection": tuilib.getinfo_tui},
{"Check mempool": tuilib.print_mempool},
{"Create token": tuilib.token_create_tui},
{"Create oracle": tuilib.oracle_create_tui},
{"Register as publisher for oracle": tuilib.oracle_register_tui},
{"Subscribe on oracle (+UTXO generator)": tuilib.oracle_subscription_utxogen},
{"Bind Gateway": tuilib.gateways_bind_tui},
{"Exit": exit}
]
def main():
while True:
os.system('clear')
print(tuilib.colorize(header, 'pink'))
print(tuilib.colorize('CLI version 0.2\n', 'green'))
for item in menuItems:
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0])
choice = input(">> ")
try:
if int(choice) < 0:
raise ValueError
# Call the matching function
if list(menuItems[int(choice)].keys())[0] == "Exit":
list(menuItems[int(choice)].values())[0]()
else:
list(menuItems[int(choice)].values())[0](rpc_connection)
except (ValueError, IndexError):
pass
if __name__ == "__main__":
while True:
try:
print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n"
"Please provide asset chain RPC connection details for initialization", "blue"))
rpc_connection = tuilib.rpc_connection_tui()
rpclib.getinfo(rpc_connection)
except Exception:
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink"))
else:
print(tuilib.colorize("Succesfully connected!\n", "green"))
with (open("lib/logo.txt", "r")) as logo:
for line in logo:
print(line, end='')
time.sleep(0.04)
print("\n")
break
main()