Skip to content

Commit 76f6478

Browse files
committed
Update AWOC. Add Sentinel Health Check, MD icons - issue #69
1 parent c8bd1f5 commit 76f6478

File tree

6 files changed

+60
-6
lines changed

6 files changed

+60
-6
lines changed

src/awoc/datum/world.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3960,7 +3960,7 @@
39603960
"Area KM2": "780580"
39613961
},
39623962
{
3963-
"Country Name": "Türkiye",
3963+
"Country Name": "T\u00FCrkiye",
39643964
"ISO2": "TR",
39653965
"ISO3": "TUR",
39663966
"TLD": "tr",

src/cli/sentinel.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class NodeTreeData():
2626
NodeScores = {}
2727
NodeLocations = {}
2828
NodeTypes = {}
29+
NodeHealth = {}
2930

3031
def __init__(self, node_tree):
3132
if not node_tree:
@@ -117,6 +118,32 @@ def get_nodes(self, latency, *kwargs):
117118
self.GetNodeScores()
118119
self.GetNodeLocations()
119120
self.GetNodeTypes()
121+
self.GetHealthCheckData()
122+
123+
124+
def GetHealthCheckData(self):
125+
Request = HTTPRequests.MakeRequest(TIMEOUT=2)
126+
http = Request.hadapter()
127+
try:
128+
r = http.get(HTTParams.HEALTH_CHECK) #specify a constant in konstants.py
129+
data = r.json()
130+
131+
for nodehealthdata in data['result']:
132+
# integrity check
133+
if nodehealthdata['status'] != 1:
134+
self.NodeHealth[nodehealthdata['addr']] = False
135+
elif "info_fetch_error " in nodehealthdata:
136+
self.NodeHealth[nodehealthdata['addr']] = False
137+
elif "config_exchange_error" in nodehealthdata:
138+
self.NodeHealth[nodehealthdata['addr']] = False
139+
elif "location_fetch_error" in nodehealthdata:
140+
self.NodeHealth[nodehealthdata['addr']] = False
141+
else:
142+
self.NodeHealth[nodehealthdata['addr']] = True
143+
144+
145+
except Exception as e:
146+
print(str(e))
120147

121148
def GetNodeScores(self):
122149
Request = HTTPRequests.MakeRequest(TIMEOUT=3)

src/geography/continents.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class OurWorld():
132132
'Tajikistan': [38.6281733, 70.8156541],
133133
'Thailand': [14.8971921, 100.83273],
134134
'Turkey': [38.9597594, 34.9249653],
135+
'Türkiye': [38.9597594, 34.9249653],
135136
'United Arab Emirates': [24.0002488, 53.9994829],
136137
'Uzbekistan': [41.32373, 63.9528098],
137138
'Vietnam': [15.9266657, 107.9650855],

src/kv/meile.kv

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ WindowManager:
581581
size: "180dp", "180dp"
582582
pos_hint: {"center_x": .5, "center_y": .5}
583583
orientation: "vertical"
584-
padding: 10,10
584+
#padding: 10,10
585585
border_radius: 20
586586
radius: [10]
587587
md_bg_color: get_color_from_hex("#121212")
@@ -600,6 +600,8 @@ WindowManager:
600600
city: " "
601601
icon: ""
602602
tooltip: ""
603+
healthcheck: ""
604+
healthchecktooltip: ""
603605
ripple_behavior: True
604606
on_press: root.subscribe_to_node(root.price_text, root.hourly_price_text, root.address_text, root.moniker_text)
605607
MDGridLayout:
@@ -624,10 +626,7 @@ WindowManager:
624626
font_size: "10sp"
625627
text_color: (0/255.0,141/255.0,155/255.0,255/255.0)
626628
pos_hint: {"x" : 0, "top" : 1.125}
627-
TooltipMDIconButton:
628-
icon: root.icon
629-
tooltip_text: root.tooltip
630-
pos_hint: {"x" : .265, "top" : .80}
629+
631630
MDLabel:
632631
text: root.type_text
633632
theme_text_color: "Custom"
@@ -710,6 +709,16 @@ WindowManager:
710709
pos_hint: {"x" : .44 , "top": .95 }
711710
size_hint: None, .525
712711

712+
TooltipMDIconButton:
713+
icon: root.icon
714+
tooltip_text: root.tooltip
715+
pos_hint: {"x" : .445, "top" : .40}
716+
TooltipMDIconButton:
717+
icon: root.healthcheck
718+
tooltip_text: root.healthchecktooltip
719+
pos_hint: {"x" : .475, "top" : .40 }
720+
size_hint: None, None
721+
713722
MDLabel:
714723
text: root.country_text
715724
theme_text_color: "Custom"

src/typedef/konstants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class HTTParams():
3838
'https://rpc-sentinel-ia.cosmosia.notional.ventures:443']
3939
GRPC = "grpc+http://aimokoivunen.mathnodes.com:9090/"
4040
#GRPC = "grpc+http://128.199.90.172:9090/"
41+
HEALTH_CHECK = "https://api.health.sentinel.co/v1/records"
4142
NODE_SCORE_ENDPOINT = "/api/nodescores"
4243
NODE_LOCATION_ENDPOINT = "/api/nodelocations"
4344
NODE_TYPE_ENDPOINT = "/api/nodetypes"
@@ -74,6 +75,8 @@ class MeileColors():
7475
INACTIVE_DIALOG_BG_COLOR = "#50507c"
7576
FONT_FACE = "fonts/mplus-2c-bold.ttf"
7677
MAP_MARKER = "imgs/location_pin.png"
78+
HEALTH_ICON = "shield-plus"
79+
SICK_ICON = "emoticon-sick"
7780

7881

7982
class NodeKeys():

src/ui/screens.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,18 @@ def add_rv_data(self, node, flagloc):
14361436
IconButton = "alpha-r-circle"
14371437
ToolTipText = "Residential"
14381438

1439+
if node[NodeKeys.NodesInfoKeys[1]].lstrip().rstrip() in self.NodeTree.NodeHealth:
1440+
if self.NodeTree.NodeHealth[node[NodeKeys.NodesInfoKeys[1]].lstrip().rstrip()]:
1441+
HealthButton = MeileColors.HEALTH_ICON
1442+
HealthToolTip = "Passed Sentinel Health Check"
1443+
else:
1444+
HealthButton = MeileColors.SICK_ICON
1445+
HealthToolTip = "Failed Sentinel Health Check"
1446+
1447+
else:
1448+
HealthButton = MeileColors.SICK_ICON
1449+
HealthToolTip = "Failed Sentinel Health Check"
1450+
14391451
self.ids.rv.data.append(
14401452
{
14411453
"viewclass" : "RecycleViewRow",
@@ -1451,6 +1463,8 @@ def add_rv_data(self, node, flagloc):
14511463
"city" : city,
14521464
"icon" : IconButton,
14531465
"tooltip" : ToolTipText,
1466+
"healthcheck" : HealthButton,
1467+
"healthchecktooltip" : HealthToolTip,
14541468
"speed_image" : self.MeileConfig.resource_path(speedimage),
14551469
"source_image" : self.MeileConfig.resource_path(flagloc)
14561470

0 commit comments

Comments
 (0)