This repository was archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslave.py
More file actions
43 lines (34 loc) · 1.31 KB
/
slave.py
File metadata and controls
43 lines (34 loc) · 1.31 KB
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
"""I send my multichain username and password and my ip to a master node so he can control my local
multichan instance """
import http.client
import json
import socket
from time import sleep
from ..data_acquisition.multichain_connector import read_user_and_password, read_rpc_port
from ..project_logger import set_up_logging
LOG = set_up_logging(__name__)
def get_credentials():
user, password = read_user_and_password()
return user, password, read_rpc_port()
def send_credentials():
credentials_sent = False
while not credentials_sent:
try:
conn = http.client.HTTPConnection('masternode', 60000)
headers = {'Content-type': 'application/json',
'Accept': 'application/json'}
user, password, rpc_port = get_credentials()
credentials = {'user': user,
'password': password,
'host': socket.gethostbyname(socket.gethostname()),
'rpc_port': rpc_port}
json_data = json.dumps(credentials)
conn.request('POST', '/post', json_data, headers)
credentials_sent = True
except Exception as error:
LOG.error(error)
sleep(5)
if __name__ == '__main__':
sleep(10)
send_credentials()
sleep(60)