Don't fail if one of the printers is unreachable/not responding

This commit is contained in:
Adam Goldsmith 2022-03-29 14:16:21 -04:00
parent 4f28ea21fe
commit 63e28a0c67

View File

@ -9,8 +9,13 @@ from google_calendar import CalendarService
def get_printer_job(calendar, printer):
octoprint_client = OctoRest(url=printer["url"], apikey=printer["apikey"])
current_job = octoprint_client.job_info()
try:
octoprint_client = OctoRest(url=printer["url"], apikey=printer["apikey"])
current_job = octoprint_client.job_info()
except Exception as e:
print(f"Failed to get current job for {printer['name']}: {e}")
return
if current_job["state"] == "Printing":
now = datetime.utcnow()
start = now - timedelta(seconds=current_job["progress"]["printTime"])