-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (36 loc) · 1.16 KB
/
main.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
import os.path, requests, json, requests, uuid
##############
# Init Start #
##############
if not os.path.isfile('./config.json'):
print("Configuration file not found...")
f = open('error-logs.txt', 'a')
f.write("config.json was not found...\n")
f.close()
exit()
with open('config.json', 'r') as jsonfile:
config = json.load(jsonfile)
if config['apikey'] == "":
f = open('error-logs.txt', 'a')
f.write("The Api Key in config.json is unspecified.\n")
f.close()
exit()
if config['devicename'] == "":
f = open('error-logs.txt', 'a')
f.write("The Device Name in config.json is unspecified.\n")
f.close()
exit()
############
# Init End #
############
def pingServer():
URL = 'http://ddns.defi-mining.nl/api/sync.php?uniqueid=' + str(uuid.getnode())
for values in config.items():
URL += f"&{values[0]}={values[1]}"
print(URL)
r = requests.get(URL).json()
if r['response'] != 'SUCCESS':
f = open('error-logs.txt', 'a')
f.write(f"An error occurred trying to synchronise this device with the Glush server: {r['error']}\n")
f.close()
pingServer()