-
Notifications
You must be signed in to change notification settings - Fork 0
/
rig_cond.py
46 lines (28 loc) · 1.01 KB
/
rig_cond.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
import urllib.request
import json
import os
def find(key, dictionary):
for k, v in dictionary.items():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
if isinstance(d, dict):
for result in find(key, d):
yield result
js = urllib.request.urlopen(address)
content = js.read()
data = json.loads(content.decode("utf8"))
final1 = list(find(value, data))
if string in final1:
check = 'No Problem'
else:
os.system('echo "The monitoring system reported a problem with the condition of the rig, check your rig portal" | mail -v -s "ETHOS Worker 5f8cab Update" WRITE YOUR EMAIL HERE')
check = 'Yes.. PROBLEM'
print('Ethos address: ', address)
print('Current Condition: ', final1)
print('Notification is for: ', string)
print('Is there a problem? ', check)