Skip to content

Commit 435666f

Browse files
authored
Add state number for out of service lab computers (#205)
* Add state number for out of service lab computers Closes #192 * Simplify lab computer status code handling
1 parent 0ce1cde commit 435666f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pittapi/lab.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,20 @@ def get_one_lab_data(lab_name: str) -> Lab:
100100
# Off: 0
101101
# Available: 1
102102
# In Use: 2
103-
# Out of Service Unknown (just going to use default condition to handle this)
104-
# TODO: find out status number for Out of Service
103+
# Out of Service: 3
104+
# https://github.com/pittcsc/PittAPI/issues/192#issuecomment-2323735463
105105
for computer_info in lab_data["state"].values():
106-
if computer_info["up"] == 0:
106+
up = computer_info["up"]
107+
if up == 0:
107108
off_computers += 1
108-
elif computer_info["up"] == 1:
109+
elif up == 1:
109110
available_computers += 1
110-
elif computer_info["up"] == 2:
111+
elif up == 2:
111112
in_use_computers += 1
112-
else:
113+
elif up == 3:
113114
out_of_service_computers += 1
115+
else:
116+
raise LabAPIError(f"Unknown 'up' value for {computer_info["addr"]} in {name}: {up}")
114117

115118
return Lab(
116119
name,

0 commit comments

Comments
 (0)