Bugfixing
This commit is contained in:
parent
5dd0694a98
commit
65b712972b
2 changed files with 6 additions and 5 deletions
|
@ -174,7 +174,7 @@ WHERE
|
|||
-- name: update-printer-level-date!
|
||||
UPDATE printers
|
||||
SET
|
||||
, last_level_date = datetime('now')
|
||||
last_level_date = datetime('now')
|
||||
WHERE
|
||||
id = :pid
|
||||
;
|
||||
|
|
|
@ -223,7 +223,7 @@ def push_jobs(app: App, db: Db) -> None:
|
|||
last_level_date = datetime.fromisoformat(last_level_date)
|
||||
|
||||
if not last_level_date or (
|
||||
datetime.utcnow() - last_level_date >= timedela(hours=24)
|
||||
datetime.utcnow() - last_level_date >= timedelta(hours=24)
|
||||
):
|
||||
log.info(f"Printer {printer.id} needs to be leveled...")
|
||||
client.gcode(
|
||||
|
@ -236,6 +236,7 @@ def push_jobs(app: App, db: Db) -> None:
|
|||
client.select(Path(file.path).name)
|
||||
client.start()
|
||||
db.start_job(jid=job.id)
|
||||
|
||||
except TimeoutError:
|
||||
pass
|
||||
|
||||
|
@ -284,7 +285,7 @@ def pull_jobs(app: App, db: Db) -> None:
|
|||
except HTTPError:
|
||||
printer_state = {"disconnected": True, "error": True}
|
||||
|
||||
if job_state.get("progress", {}).get("completion", 0.0) == 100.0:
|
||||
if (job_state.get("progress", {}).get("completion") or 0.0) == 100.0:
|
||||
# Debounce jobs which JUST started from immediately completing due to a data race
|
||||
start_date = datetime.fromisoformat(job.started_at)
|
||||
runtime = datetime.utcnow() - start_date
|
||||
|
@ -292,9 +293,9 @@ def pull_jobs(app: App, db: Db) -> None:
|
|||
log.info(f"Job {job.id} has succeeded")
|
||||
db.finish_job(jid=job.id, state="success")
|
||||
|
||||
elif job_state.get("progress", {}).get("completion", 0.0) < 100.0:
|
||||
elif (job_state.get("progress", {}).get("completion") or 0.0) < 100.0:
|
||||
time_left = float(
|
||||
job_state.get("progress", {}).get("printTimeLeft", "3600.0")
|
||||
job_state.get("progress", {}).get("printTimeLeft") or "3600.0"
|
||||
)
|
||||
db.update_job_time_left(jid=job.id, time_left=time_left)
|
||||
|
||||
|
|
Loading…
Reference in a new issue