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: ...@@ -42,7 +42,6 @@ class KortAPI:
def get_next_job(self, printer_id: int) -> Optional[dict[str, Any]]: def get_next_job(self, printer_id: int) -> Optional[dict[str, Any]]:
r = self._do_request("GET", "next_job", [printer_id]) r = self._do_request("GET", "next_job", [printer_id])
print(r)
if r.get("status") == "no_job": if r.get("status") == "no_job":
return None return None
return r return r
...@@ -77,8 +76,6 @@ class KortAPI: ...@@ -77,8 +76,6 @@ class KortAPI:
raise ConfigurationException("No client_secret set.") raise ConfigurationException("No client_secret set.")
if not self.settings.base_url: if not self.settings.base_url:
raise ConfigurationException("No base_url set.") raise ConfigurationException("No base_url set.")
if not self.settings.access_token:
raise ConfigurationException("No access_token set.")
def _do_request( def _do_request(
self, method: str, url: str, attrs: Optional[Sequence] = None, **kwargs self, method: str, url: str, attrs: Optional[Sequence] = None, **kwargs
......
...@@ -43,6 +43,9 @@ class PrintClient: ...@@ -43,6 +43,9 @@ class PrintClient:
fg="red", fg="red",
) )
if self.card_detector_in_process and self.card_detector: 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() self.card_detector.abort()
else: else:
printer_status = "online" printer_status = "online"
...@@ -66,6 +69,9 @@ class PrintClient: ...@@ -66,6 +69,9 @@ class PrintClient:
self.printer_id, "offline", "Printer client was stopped by user." self.printer_id, "offline", "Printer client was stopped by user."
) )
if self.card_detector and self.card_detector_in_process: 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() self.card_detector.abort()
raise raise
...@@ -93,7 +99,6 @@ class PrintClient: ...@@ -93,7 +99,6 @@ class PrintClient:
def step(self): def step(self):
self.printer_config = self.api.get_printer() self.printer_config = self.api.get_printer()
print(self.printer_config)
self.printer_id = self.printer_config["id"] self.printer_id = self.printer_config["id"]
...@@ -102,11 +107,11 @@ class PrintClient: ...@@ -102,11 +107,11 @@ class PrintClient:
self.card_detector_in_process = False self.card_detector_in_process = False
if self.card_detector: if self.card_detector:
self.interactive = self.card_detector.interactive self.interactive = self.card_detector.interactive
click.secho(f"Clear card detector {self.card_detector.id}")
self.card_detector.clear() self.card_detector.clear()
next_job = self.api.get_next_job(self.printer_id) next_job = self.api.get_next_job(self.printer_id)
print(next_job)
if next_job: if next_job:
job_id = next_job["id"] job_id = next_job["id"]
click.secho("Got new print job {}".format(next_job), fg="green") click.secho("Got new print job {}".format(next_job), fg="green")
...@@ -118,7 +123,9 @@ class PrintClient: ...@@ -118,7 +123,9 @@ class PrintClient:
if not self.printer_config.get("generate_number_on_server"): if not self.printer_config.get("generate_number_on_server"):
# Now do something to set the number, but irrelevant for this example # 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: if self.card_detector:
self.card_detector_in_process = True self.card_detector_in_process = True
chip_number = self.card_detector.read_id() chip_number = self.card_detector.read_id()
...@@ -131,6 +138,7 @@ class PrintClient: ...@@ -131,6 +138,7 @@ class PrintClient:
raise KortClientException("No card detector configured") raise KortClientException("No card detector configured")
if self.with_printer and next_job["card"]["chip_number"]: if self.with_printer and next_job["card"]["chip_number"]:
click.secho("Download card PDF file ...")
# Download PDF file # Download PDF file
with tempfile.NamedTemporaryFile("wb") as f: with tempfile.NamedTemporaryFile("wb") as f:
r = requests.get( r = requests.get(
......
[tool.poetry] [tool.poetry]
name = "kort-client" name = "kort-client"
version = "0.1.0" version = "0.1.1"
description = "" description = ""
authors = ["Jonathan Weth <git@jonathanweth.de>"] authors = ["Jonathan Weth <git@jonathanweth.de>"]
......