-
Notifications
You must be signed in to change notification settings - Fork 5
/
walletsyncer.py
55 lines (42 loc) · 1.67 KB
/
walletsyncer.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
from tipbot.get_info import *
from argparse import ArgumentParser
from logger import tipper_logger
import helper
import traceback
import time
import os, sys
parser = ArgumentParser()
parser.add_argument("-p", "--password", dest="password", default="password")
parser.add_argument("-t", "--testnet", action="store_true", help="Whether to run MoneroTipper on testnet")
args = parser.parse_args()
class HiddenPrints:
def __enter__(self):
self._original_stdout = sys.stdout
sys.stdout = open(os.devnull, 'w')
def __exit__(self, exc_type, exc_val, exc_tb):
sys.stdout.close()
sys.stdout = self._original_stdout
sync_time = 360
def main():
helper.testnet = args.testnet
helper.password = args.password
if helper.testnet:
helper.ports.ports_to_testnet()
try:
while True:
for i in sorted(os.listdir("wallets/" + ("testnet/" if args.testnet else "mainnet/"))):
if not "." in i:
start = int(round(time.time() * 1000))
print("Opening " + i + "'s wallet")
with HiddenPrints():
get_info(wallet_name=i, private_info=False, password=args.password, port=helper.ports.wallet_sync_port, timeout=sync_time)
if int(round(time.time()*1000))-start > sync_time*1000 - 10000:
print("Warn: " + i + "'s wallet is likely unsynced")
print("Taking a break...")
time.sleep(sync_time) # Poor CPU
except Exception as e:
tipper_logger.log("walletsyncer error: " + str(e))
traceback.print_exc()
main()
if __name__ == "__main__":
main()