Skip to content

Commit 42768be

Browse files
committed
lint fixes
1 parent 26b979b commit 42768be

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed
+44-36
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,95 @@
1+
"""Push one or more folders to one or more robots."""
12
import subprocess
23
import multiprocessing
34
import json
4-
import time
5+
56
global folders
67
# Opentrons folders that can be pushed to robot
78
folders = [
8-
'abr-testing',
9-
'hardware-testing',
10-
'all',
11-
'other',
9+
"abr-testing",
10+
"hardware-testing",
11+
"all",
12+
"other",
1213
]
1314

1415

15-
16-
def push_subroutine(cmd: str):
17-
"""Pushes specified folder to specified robot"""
16+
def push_subroutine(cmd: str) -> None:
17+
"""Pushes specified folder to specified robot."""
1818
try:
1919
subprocess.run(cmd)
20-
except Exception as e:
21-
print('failed to push folder')
20+
except Exception:
21+
print("failed to push folder")
2222
raise
23-
23+
24+
2425
def main(folder_to_push: str, robot_to_push: str) -> int:
25-
"""Main process"""
26-
cmd = 'make -C {folder} push-ot3 host={ip}'
26+
"""Main process!"""
27+
cmd = "make -C {folder} push-ot3 host={ip}"
2728
robot_ip_path = ""
28-
push_cmd = ''
29+
push_cmd = ""
2930
folder_int = int(folder_to_push)
30-
if folders[folder_int].lower() == 'all':
31-
if robot_to_push.lower() == 'all':
32-
robot_ip_path = input('Path to robot ips: ')
33-
with open(robot_ip_path, 'r') as ip_file:
31+
if folders[folder_int].lower() == "all":
32+
if robot_to_push.lower() == "all":
33+
robot_ip_path = input("Path to robot ips: ")
34+
with open(robot_ip_path, "r") as ip_file:
3435
robot_json = json.load(ip_file)
35-
robot_ips = robot_json.get('ip_address_list')
36+
robot_ips_dict = robot_json.get("ip_address_list")
37+
robot_ips = list(robot_ips_dict.keys())
3638
ip_file.close()
3739
else:
3840
robot_ips = [robot_to_push]
3941
for folder_name in folders[:-2]:
40-
#Push all folders to all robots
42+
# Push all folders to all robots
4143
for robot in robot_ips:
42-
print_proc = multiprocessing.Process(target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",))
44+
print_proc = multiprocessing.Process(
45+
target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",)
46+
)
4347
print_proc.start()
4448
print_proc.join()
4549
push_cmd = cmd.format(folder=folder_name, ip=robot)
46-
process = multiprocessing.Process(target=push_subroutine, args=(push_cmd,))
50+
process = multiprocessing.Process(
51+
target=push_subroutine, args=(push_cmd,)
52+
)
4753
process.start()
4854
process.join()
49-
print_proc = multiprocessing.Process(target=print, args=(f"Done!\n\n"))
55+
print_proc = multiprocessing.Process(target=print, args=("Done!\n\n"))
5056
print_proc.start()
5157
print_proc.join()
5258
else:
53-
54-
if folder_int == (len(folders)-1):
55-
folder_name = input('Which folder? ')
59+
60+
if folder_int == (len(folders) - 1):
61+
folder_name = input("Which folder? ")
5662
else:
5763
folder_name = folders[folder_int]
58-
if robot_to_push.lower() == 'all':
64+
if robot_to_push.lower() == "all":
5965
robot_ip_path = input("Path to robot ips: ")
60-
with open(robot_ip_path, 'r') as ip_file:
66+
with open(robot_ip_path, "r") as ip_file:
6167
robot_json = json.load(ip_file)
62-
robot_ips = robot_json.get('ip_address_list')
68+
robot_ips = robot_json.get("ip_address_list")
6369
ip_file.close()
6470
else:
6571
robot_ips = [robot_to_push]
6672

6773
# Push folder to robots
6874
for robot in robot_ips:
69-
print_proc = multiprocessing.Process(target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",))
75+
print_proc = multiprocessing.Process(
76+
target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",)
77+
)
7078
print_proc.start()
7179
print_proc.join()
7280
push_cmd = cmd.format(folder=folder_name, ip=robot)
7381
process = multiprocessing.Process(target=push_subroutine, args=(push_cmd,))
7482
process.start()
7583
process.join()
76-
print_proc = multiprocessing.Process(target=print, args=(f"Done!\n\n",))
84+
print_proc = multiprocessing.Process(target=print, args=("Done!\n\n",))
7785
print_proc.start()
7886
print_proc.join()
79-
return(0)
87+
return 0
88+
8089

81-
82-
if __name__ == '__main__':
90+
if __name__ == "__main__":
8391
for i, folder in enumerate(folders):
8492
print(f"{i}) {folder}")
85-
folder_to_push = input('Please Select a Folder to Push: ')
93+
folder_to_push = input("Please Select a Folder to Push: ")
8694
robot_to_push = input("Type in robots ip (type all for all): ")
87-
print(main(folder_to_push, robot_to_push))
95+
print(main(folder_to_push, robot_to_push))

0 commit comments

Comments
 (0)