Skip to content

Commit

Permalink
Add state number for out of service lab computers (#205)
Browse files Browse the repository at this point in the history
* Add state number for out of service lab computers

Closes #192

* Simplify lab computer status code handling
  • Loading branch information
winterqt authored Dec 9, 2024
1 parent 0ce1cde commit 435666f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pittapi/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,20 @@ def get_one_lab_data(lab_name: str) -> Lab:
# Off: 0
# Available: 1
# In Use: 2
# Out of Service Unknown (just going to use default condition to handle this)
# TODO: find out status number for Out of Service
# Out of Service: 3
# https://github.com/pittcsc/PittAPI/issues/192#issuecomment-2323735463
for computer_info in lab_data["state"].values():
if computer_info["up"] == 0:
up = computer_info["up"]
if up == 0:
off_computers += 1
elif computer_info["up"] == 1:
elif up == 1:
available_computers += 1
elif computer_info["up"] == 2:
elif up == 2:
in_use_computers += 1
else:
elif up == 3:
out_of_service_computers += 1
else:
raise LabAPIError(f"Unknown 'up' value for {computer_info["addr"]} in {name}: {up}")

return Lab(
name,
Expand Down

0 comments on commit 435666f

Please sign in to comment.