Skip to content

Commit 4e8eecf

Browse files
committed
linting
1 parent cafb4c4 commit 4e8eecf

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

scripts/hooks/discovery/20.add_routes.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,29 @@ def on_discovery_updated(robots, selected_robots, **_):
3232
parts = pc_ip.split(".")[:-1]
3333
net_ip = ".".join(parts + ["0"])
3434
host_ip = ".".join(parts[:2] + ["0", parts[2]])
35-
36-
existing_routes = ip.get_routes(dst=net_ip + '/' + str(netmask))
35+
36+
existing_routes = ip.get_routes(dst=net_ip + "/" + str(netmask))
3737

3838
valid_route = False
3939
if existing_routes:
4040
gateway = next(
4141
(
42-
value for key, value in existing_routes[0]["attrs"]
42+
value
43+
for key, value in existing_routes[0]["attrs"]
4344
if key == "RTA_GATEWAY"
4445
),
4546
None,
4647
)
4748
if gateway == host_ip:
4849
valid_route = True
49-
50+
5051
if not valid_route:
51-
print(
52-
f"Adding route to {net_ip}/{netmask} via host pc"
53-
)
52+
print(f"Adding route to {net_ip}/{netmask} via host pc")
5453
command = (
5554
f"ip.route('add', dst='{net_ip}/{netmask}', gateway='{host_ip}')\n"
5655
)
5756
routes_to_add += command
58-
57+
5958
if routes_to_add != "":
6059
ip_route_code = f"""from pyroute2 import IPRoute
6160
ip = IPRoute()
@@ -64,7 +63,4 @@ def on_discovery_updated(robots, selected_robots, **_):
6463
print(
6564
"Privilege escalation required to add routes, running commands with sudo..."
6665
)
67-
subprocess.run(
68-
["sudo", "python3", "-c", ip_route_code],
69-
check=True
70-
)
66+
subprocess.run(["sudo", "python3", "-c", ip_route_code], check=True)

0 commit comments

Comments
 (0)