Verified Commit 24add338 authored by Jakob Moser's avatar Jakob Moser
Browse files

Lint files

parent 457df662
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ def _initialize_card_reader_and_run_with_crash() -> None:
        try:
            _initialize_card_reader_and_run()
        except CardReaderException as e:
            logging.error("Fatal: Card reader errored, reinitialization needed. Crashing the application.")
            logging.error(
                "Fatal: Card reader errored, reinitialization needed. Crashing the application."
            )
            logging.exception(e)
            exit(42)

@@ -85,9 +87,7 @@ def launch_application() -> None:

def launch_application_as_daemon() -> None:
    logging.info("Launching main application as daemon thread")
    Thread(
        target=launch_application, daemon=True
    ).start()
    Thread(target=launch_application, daemon=True).start()


logging.info("Creating wire.Server")
+0 −2
Original line number Diff line number Diff line
import argparse

from rich import print

from poolpay import db, paths
from poolpay.admin import app

+10 −4
Original line number Diff line number Diff line
from collections.abc import Callable
import logging
from collections.abc import Callable
from time import sleep

import RPi.GPIO as GPIO
from pirc522 import RFID
from pirc522.rfid import logger as pirc522_logger  # We need this for some ugly monkey-patching, see below
from pirc522.rfid import (
    logger as pirc522_logger,
)  # We need this for some ugly monkey-patching, see below

from poolpay.card.CardReader import CardReader
from poolpay.card.raise_on_error_e1 import raise_on_error_e1
@@ -51,11 +53,15 @@ class Pirc522CardReader(CardReader):

            if uid is None:
                if card_recently_placed and self._handle_removal is not None:
                    logging.debug("Cannot read uid, but was previously able to => card removed")
                    logging.debug(
                        "Cannot read uid, but was previously able to => card removed"
                    )
                    self._handle_removal(self)
                card_recently_placed = False
            elif not card_recently_placed:
                logging.debug("Can read id, but was not previously able to => card newly placed")
                logging.debug(
                    "Can read id, but was not previously able to => card newly placed"
                )
                card_recently_placed = True
                handle_card(self)

+8 −3
Original line number Diff line number Diff line
from dataclasses import dataclass, field
import logging
from dataclasses import dataclass, field
from time import monotonic, sleep

from poolpay import db
@@ -69,7 +69,10 @@ class Director:
        logging.debug("Card removed")
        self._last_card_removed_at = monotonic()
        self._ensure_minimum_presentation_time()
        if self._next_scene_on_card_placed is self.play.Balance and self._last_card_presentation_failed:
        if (
            self._next_scene_on_card_placed is self.play.Balance
            and self._last_card_presentation_failed
        ):
            # If the user wanted to see their balance, but the card detection failed, show the balance
            # next time a card is presented
            # TODO Move this hotfix in a better place
@@ -101,7 +104,9 @@ class Director:
        # This is how long we still have to present the scene
        sleep_time = max(0, minimum_presentation_time - elapsed_presentation_time)

        logging.debug(f"Ensuring minimum presentation time. Elapsed: {elapsed_presentation_time}s, Minimum: {minimum_presentation_time}s => Sleep time: {sleep_time}s")
        logging.debug(
            f"Ensuring minimum presentation time. Elapsed: {elapsed_presentation_time}s, Minimum: {minimum_presentation_time}s => Sleep time: {sleep_time}s"
        )
        sleep(sleep_time)
        logging.debug("Ensured minium presentation time.")