Skip to content
Snippets Groups Projects
Verified Commit a1d8f89d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Improve logging

parent 352268f3
Branches master
No related tags found
No related merge requests found
......@@ -42,7 +42,6 @@ class KortAPI:
def get_next_job(self, printer_id: int) -> Optional[dict[str, Any]]:
r = self._do_request("GET", "next_job", [printer_id])
print(r)
if r.get("status") == "no_job":
return None
return r
......
......@@ -43,6 +43,9 @@ class PrintClient:
fg="red",
)
if self.card_detector_in_process and self.card_detector:
click.secho(
f"Abort card detection process with card detector {self.card_detector.id}"
)
self.card_detector.abort()
else:
printer_status = "online"
......@@ -66,6 +69,9 @@ class PrintClient:
self.printer_id, "offline", "Printer client was stopped by user."
)
if self.card_detector and self.card_detector_in_process:
click.secho(
f"Abort card detection process with card detector {self.card_detector.id}"
)
self.card_detector.abort()
raise
......@@ -93,7 +99,6 @@ class PrintClient:
def step(self):
self.printer_config = self.api.get_printer()
print(self.printer_config)
self.printer_id = self.printer_config["id"]
......@@ -102,11 +107,11 @@ class PrintClient:
self.card_detector_in_process = False
if self.card_detector:
self.interactive = self.card_detector.interactive
click.secho(f"Clear card detector {self.card_detector.id}")
self.card_detector.clear()
next_job = self.api.get_next_job(self.printer_id)
print(next_job)
if next_job:
job_id = next_job["id"]
click.secho("Got new print job {}".format(next_job), fg="green")
......@@ -118,7 +123,9 @@ class PrintClient:
if not self.printer_config.get("generate_number_on_server"):
# Now do something to set the number, but irrelevant for this example
click.secho("Generate number on server disabled", fg="yellow")
click.secho(
"Generate number on server disabled, read chip number", fg="yellow"
)
if self.card_detector:
self.card_detector_in_process = True
chip_number = self.card_detector.read_id()
......@@ -131,6 +138,7 @@ class PrintClient:
raise KortClientException("No card detector configured")
if self.with_printer and next_job["card"]["chip_number"]:
click.secho("Download card PDF file ...")
# Download PDF file
with tempfile.NamedTemporaryFile("wb") as f:
r = requests.get(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment