color arches based on latency
This commit is contained in:
parent
901c1e2a17
commit
9bddcfaa7e
15
kglobe.py
15
kglobe.py
@ -110,7 +110,7 @@ def traceroute(target: str):
|
|||||||
# exclude common local network addreses
|
# exclude common local network addreses
|
||||||
continue
|
continue
|
||||||
hop = database.get_all(ip)
|
hop = database.get_all(ip)
|
||||||
hop.latency = latency
|
hop.latency = float(latency)
|
||||||
hops.append(hop)
|
hops.append(hop)
|
||||||
return hops
|
return hops
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ async def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
for point in points_3d:
|
for point in points_3d:
|
||||||
city_marker = pv.Sphere(center=point, radius=0.02)
|
city_marker = pv.Sphere(center=point, radius=0.01)
|
||||||
plotter.add_mesh(city_marker, color="blue")
|
plotter.add_mesh(city_marker, color="blue")
|
||||||
|
|
||||||
labels = [ f'{_.country_short}: {_.latency}ms' for _ in locations]
|
labels = [ f'{_.country_short}: {_.latency}ms' for _ in locations]
|
||||||
@ -174,7 +174,16 @@ async def main():
|
|||||||
for i in range(len(points_3d[:-1])):
|
for i in range(len(points_3d[:-1])):
|
||||||
arch = generate_arch(points_3d[i], points_3d[i + 1], height_factor=0.2)
|
arch = generate_arch(points_3d[i], points_3d[i + 1], height_factor=0.2)
|
||||||
line = pv.lines_from_points(arch, close=False)
|
line = pv.lines_from_points(arch, close=False)
|
||||||
plotter.add_mesh(line, color="red", line_width=2)
|
diff = locations[i+1].latency - locations[i].latency
|
||||||
|
if diff < 20:
|
||||||
|
color="green"
|
||||||
|
elif diff < 0.5:
|
||||||
|
color = "yellow"
|
||||||
|
elif diff < 0.7:
|
||||||
|
color = "orange"
|
||||||
|
else:
|
||||||
|
color = "red"
|
||||||
|
plotter.add_mesh(line, color=color, line_width=2)
|
||||||
|
|
||||||
kitty.hide_cursor()
|
kitty.hide_cursor()
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user