Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AlekSIS/libs/kort-client
1 result
Show changes
Commits on Source (3)
......@@ -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
......@@ -77,8 +76,6 @@ class KortAPI:
raise ConfigurationException("No client_secret set.")
if not self.settings.base_url:
raise ConfigurationException("No base_url set.")
if not self.settings.access_token:
raise ConfigurationException("No access_token set.")
def _do_request(
self, method: str, url: str, attrs: Optional[Sequence] = None, **kwargs
......
......@@ -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(
......
[tool.poetry]
name = "kort-client"
version = "0.1.0"
version = "0.1.1"
description = ""
authors = ["Jonathan Weth <git@jonathanweth.de>"]
......